转自 http://blog.csdn.net/zhaozy55555/article/details/7671491
贴出一个删除本地xml文件的函数,文件名为:”.weatherxml“
函数首先获取程序的home路径,再获取文件全路径,之后调用NSFileManager:removeItemAtPath方法删除指定文件
-(void)delWeatherXml
{
NSString * HomeDirectory;
NSString * theFilePath;
NSArray * arry=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
if([arry count])
{
HomeDirectory= [[NSString alloc] initWithFormat:[arry objectAtIndex:0]];
NSLog(HomeDirectory);
}
theFilePath = [HomeDirectory stringByAppendingPathComponent:@".weatherxml"];
NSLog(theFilePath);
NSFileManager *defaultManager;
defaultManager = [NSFileManager defaultManager];
BOOL boolValue=[defaultManager removeItemAtPath: theFilePath error: nil];
if (boolValue)
{
NSLog(@"remove weatherxml file ok");
}
}