Delete files

Just starting out? Need help? Post your questions and find answers here.
Jeff8888
User
User
Posts: 42
Joined: Fri Jan 31, 2020 6:48 pm

Delete files

Post by Jeff8888 »

Just wanted to confirm for Deletefile(Filename$) that filename$ must be the full path name and not just the file name obtained from Nextdirectoryentry().

I am going thruough a directory and deleting files based on time of day they were created by a trail cam.
Quin
Addict
Addict
Posts: 1134
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Delete files

Post by Quin »

Nope, DeleteFile() supports both absolute and relative paths. Just tested by creating a file called test.txt, and running:

Code: Select all

DeleteFile("test.txt")
From within the same directory, and it worked.
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Delete files

Post by Demivec »

Relative paths and lone file names without a path are resolved based on the current directory.. Use the functions GetCurrentDirectory() and SetCurrentDirectory() to verify and/or set the current directory.

If you use full paths for all of your program's other file operations or the other operations are not taking place concurrently you can set the current directory to the where the deletions are taking place and this will allow you to only need the filename for the DeleteFile() function.
Post Reply