第2个回答 2016-04-24
// 文件存放目录
NSString *pngDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *FileDir = [NSString stringWithFormat:@"%@/AnnexFiles", pngDir];
NSError *err;
[fileMgr createDirectoryAtPath:FileDir withIntermediateDirectories:YES attributes:nil error:&err];
NSString *FileFullPath = [FileDir stringByAppendingPathComponent:[DBTopicAnnexData Name]];
BOOL bRet = [fileMgr fileExistsAtPath:FileFullPath];
if (bRet) {
//
NSError *err;
[fileMgr removeItemAtPath:FileFullPath error:&err];
}
或者
// 清除本地配置数据
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSString *MapLayerDataPath = [documentsDirectorystringByAppendingPathComponent:@"DBMapLayerData.xml"];
BOOL bRet = [fileMgr fileExistsAtPath:MapLayerDataPath];
if (bRet) {
//
NSError *err;
[fileMgr removeItemAtPath:MapLayerDataPath error:&err];
}本回答被网友采纳