1.判斷Bundle裡面的檔案是否存在
-(BOOL)judgeFileExist:(NSString * )fileName
{
//擷取檔案路徑
NSString *path = [[NSBundle
mainBundle] pathForResource:fileName
ofType:@""];
if(path==NULL)
returnNO;
returnYES;
}
2.判斷Doucuments 裡面的檔案是否存在
-(BOOL)judgeFileExist:(NSString * )fileName;
{
NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString * filePath=[documentsDirectory stringByAppendingPathComponent:fileName];
NSFileManager * fileManager=[NSFileManagerdefaultManager];
return [fileManager fileExistsAtPath:filePath];
}
3.得到檔案的路徑
- (NSString *)imageFilePath:(NSString *)fileNname
{
//NSString *paths = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:fileNname];
}