i used the following method to delete all the contents of the folder
NSFileManager *fm = [NSFileManager defaultManager];
NSArray* arrFilePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * strFilePath = [arrFilePath objectAtIndex:0];
NSString *directory = [strFilePath stringByAppendingPathComponent:@"Electronic_Instrumentation-Sapna_publications"];
NSError *error = nil;
for (NSString *file in [fm contentsOfDirectoryAtPath:directory error:&error])
{
directory = [directory stringByAppendingPathComponent:file];
BOOL success = [fm removeItemAtPath:directory error:&error];
file = nil;
if (!success || error)
{
NSLog(@"Failed to remove files");
}
}
but its deleting only first file in the directory
say i have 3 files in the dorectory file1.txt, file2.txt,file3.txt
when i call this method it ill delete only file1.txt but not other files , again if i call that method it ill delete file2.txt but not file3.txt
how can i fix this,,??
is there any way to delete a directory ?? thanx in advance