当我尝试将字符串写入文件时出现文件错误:
NSFileManager *filemgr;
filemgr = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex: 0];
NSString *docFile = [docDir stringByAppendingPathComponent:fileName];
if ([file fileExistsAtPath: docFile] == YES)
{ if(![formatedlogStr writeToFile:LOG_FILE_V1 atomically:YES encoding:NSUTF8StringEncoding error:&error])
{
NSLog(@"Error: %@", [error userInfo]);
}
}
这给了我一个错误:
Error: {
NSFilePath = "error_log_V1.txt";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=13 \"The operation couldn\U2019t be completed. Permission denied\"";
NSUserStringVariant = Folder;
如何解决我不知道的问题。有谁能够帮助我?