문제

I want to delete the files which are placed in a folder(inside documents folder) of documents directory. I just listed or displayed all those files on the table view , can anybody tell me how can i do this using commitEditingStyle: method. Please help me how can i achieve this.Thanks in advance.

도움이 되었습니까?

해결책

You can use the below code to delete the file from document directory:

NSError *error;
NSFileManager *fileMgr = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documents= [documentsDirectory stringByAppendingPathComponent:@"YourFolder"];
NSString *filePath = [documents stringByAppendingPathComponent:@"file2.txt"];
[fileMgr removeItemAtPath:filePath error:&error]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top