iOS 根據文件名獲取到文件路徑


根據文件名來獲取文件路徑(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"]];
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM