Hi,
Here is the tricky code for fetching document list from Directory in iPhone/iPad/iOS Application. Here, I have used code to delete all documents from My Application Document directory.
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *contents = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:NULL];
NSEnumerator *e = [contents objectEnumerator];
NSString *filename;
while ((filename = [e nextObject])) {
[fileManager removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:filename] error:nil];
}
Thanks & Regards,
Nilesh Prajapati
Here is the tricky code for fetching document list from Directory in iPhone/iPad/iOS Application. Here, I have used code to delete all documents from My Application Document directory.
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSArray *contents = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:NULL];
NSEnumerator *e = [contents objectEnumerator];
NSString *filename;
while ((filename = [e nextObject])) {
[fileManager removeItemAtPath:[documentsDirectory stringByAppendingPathComponent:filename] error:nil];
}
Thanks & Regards,
Nilesh Prajapati
No comments:
Post a Comment