Forum Discussion

sarya's avatar
sarya
Frequent Contributor
15 years ago

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

  • 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.