cancel
Showing results for 
Search instead for 
Did you mean: 

Files not getting deleted from the folder

Highlighted
Frequent Contributor

Files not getting deleted from the folder

Hi,



I have a folder with path " C:\Program Files (x86)\Report2Web Client Tools\Logs".I am trying to delete all the files in it at once.It has twenty files with name as "Burster-2010-02-10.txt" with different dates .I used this in my script as shown below but it does not do any deletion .


if (fs.FileExists(bursterpath + "Logs\\*.txt")) fsDeleteFile(bursterpath + "Logs\\*.txt", true);



Thanks,

Sumedha


(fs.FileExists(bursterpath + "Logs\\*.txt")) DeleteFile(bursterpath + "Logs\\*.txt", );Thanks,Sumedha
1 REPLY 1
Highlighted

RE: Files not getting deleted from the folder

Hi Sumedha,


The following sample script works perfectly for me:

aqFileSystem.DeleteFile("c:\\1234\\*.txt");


I suppose, the problem is actually with the aqFileSystem.FileExists method call as you need to specify full file names without wildcards in the method. If you need to use wildcards, I recommend that you use the aqFileSystem.FindFiles method instead (see the "aqFileSystem.FindFiles" help topic ( http://www.automatedqa.com/support/viewarticle.aspx?aid=3975 ) for more information).


BTW, there is no need to check whether the files exist - you can just call the aqFileSystem.DeleteFile method even if there are no files to delete.



Best regards,
Alexey

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors