NSString * realPath = [NSHomeDirectory () stringByAppendingPathComponent: @ "Documents / xx.sqlite"];
NSError * error;
NSURL * url = [NSURL URLWithString: realPath];
if ([fileManager fileExistsAtPath: realPath]) {
NSLog (@ "file exists");
[FileManager removeItemAtURL: url error: & error] ;/ / not delete oh
NSLog (@ "error =% @", error);
}
if ([fileManager copyItemAtPath: sourcePath toPath: realPath error: & error]!)
{/ / As long as you can not copy the file exists, it can not be overwritten.
NSLog (@ "% @", [error localizedDescription]);
}
else {
NSLog (@ "% @ successfully copied to the path:% @.", SourcePath, realPath);
}
Reply:
Seems to be a database file, other threads may be accessed, so can not be deleted. You try to change a file.
Reply:
How can you delete a path with NSURL?
NSString path directly delete ah.
Please refer to the following:
http://blog.csdn.net/cxsjabcabc/article/details/7167729
No comments:
Post a Comment