码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 根据文件名获取到文件路径

时间:2015-04-21 14:22:28      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

根据文件名来获取文件路径(Document目录下)

//根据文件名来获取文件路径  
- (NSString *)dataFilePath:(NSString *)sender {  
    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,  
                NSUserDomainMask,   
                YES);  
    NSString *documentDirectory = [path objectAtIndex:0];  
    return [documentDirectory stringByAppendingPathComponent:sender];  
}  
resource目录下

NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:filename];  

Cache目录下

NSArray *cache = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);     
   NSString *cachePath = [cache objectAtIndex:0] ;     
        
   NSString *voiceName = [cachePath stringByAppendingPathComponent:[sender stringByAppendingString:@".wav"]];
 

 

iOS 根据文件名获取到文件路径

标签:

原文地址:http://www.cnblogs.com/niit-soft-518/p/4444043.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!