Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I delete a file in my apps documents directory?

Tags:

xcode

iphone

Given, a file of path [[self documentsDirectory] stringByAppendingPathComponent:@"myFiles/aFile.txt"], How do I delete a file in my apps documents directory?

like image 1000
RexOnRoids Avatar asked Feb 05 '10 03:02

RexOnRoids


People also ask

How do I delete documents in My Documents folder?

Locate the item you want to delete, highlight it by left-clicking the file or folder with your mouse once, and press the Delete key. You can browse the location of the file or folder using My Computer or Windows Explorer.

How do I permanently delete files from app?

Select the item in your file explorer. Then, tap the trash button or press the three-dot menu and choose Delete. Confirm you understand deletion can't be undone and tap Delete again. This is how you should delete your files on Android.

How do I delete items in my files folder on my Iphone?

To delete a file, select it and tap the Delete button . If you delete files from the iCloud Drive folder on one device, they are automatically deleted on your other devices, too.

Will deleting files app delete files?

Answer: A: Answer: A: Files stored in the Files app WILL be deleted IF the Files app is deleted! If you have ANY important data stored in folders in the Files App, you DO NOT want to delete the Files app!


1 Answers

NSFileManager is a very handy tool:

[[NSFileManager defaultManager] removeItemAtPath: pathToFile error: &error]; 
like image 192
Ben Gottlieb Avatar answered Oct 03 '22 07:10

Ben Gottlieb