删除本地文件 #ifndef USERINFOPATH #define USERINFOPATH [NSString stringWithFormat:@"%@/%@info.plist",DOCUMENTS, [[NSUserDefaults standardUserDefaults] stringForKey:USERID]] #endif /** Delete a file **/ + (BOOL) DeleteSingleFile:(NSString *)filePath { NSError *err = nil; if (nil == filePath) { return NO; } NSFileManager *appFileManager = [NSFileManager defaultManager]; if (![appFileManager fileExistsAtPath:filePath]) { return YES; } if (![appFileManager isDeletableFileAtPath:filePath]) { return NO; } return [appFileManager removeItemAtPath:filePath error:&err;]; } //调用 if ([SupportClass DeleteSingleFile:USERINFOPATH]) { NSLog(@"删除成功"); };
时间: 2024-10-28 07:05:37