IOS-文件操作合集-待更新

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];  

}  


你可能感兴趣的:(null,Path)