sarya
14 years agoFrequent Contributor
Delete files using Wildcard not working
Hi,
I am trying to delete file "c:\Bun272010-06-02T141405.PDF" where the portion after the letter 'T' --'141405' in the filename is the file creation time and this keeps changing whenever the file is created so it cannot be hard-coded.
I tried the codes below using wildcard but that none of them works to delete the files..
(fs.FileExists('c:\\Bun27' + r2wdate + 'T*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
I am trying to delete file "c:\Bun272010-06-02T141405.PDF" where the portion after the letter 'T' --'141405' in the filename is the file creation time and this keeps changing whenever the file is created so it cannot be hard-coded.
I tried the codes below using wildcard but that none of them works to delete the files..
if (fs.FileExists('c:\\Bun27' + r2wdate + 'T*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
(fs.FileExists('c:\\Bun27' + r2wdate + 'T*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + 'T*.pdf');
if (fs.FileExists('c:\\Bun27' + r2wdate + '*.pdf')) fs.DeleteFile('c:\\Bun27' + r2wdate + '*.pdf');
if (fs.FileExists('c:\\*.pdf')) fs.DeleteFile('c:\\*.pdf');
Thanks,
Sumedha