Thursday, August 16, 2012

Remove .DS store Files from Document Directory


//clean documnt directory
NSString *folderPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 

NSError *error = nil;
NSMutableArray *dirArr = [NSMutableArray arrayWithArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:&error]];

[dirArr removeObject:@".DS_Store"];

for (NSString *file in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:folderPath error:&error]) 
{
     [[NSFileManager defaultManager] removeItemAtPath:[folderPath stringByAppendingPathComponent:file] error:&error];
}

No comments:

Post a Comment