Ask a Question

aqFileSystem.Exists: Is there a way to add wildcard characters in the filename?


aqFileSystem.Exists: Is there a way to add wildcard characters in the filename?




After I click on Download Excel button present in my application., I have a function that has to wait until download finishes using "aqFileSystem.Exists(filenameWithPath)" as a check. The download file gets downloaded in my Download folder. Let's say my file name is ReportName


So, my code looks something like this:




The above code works fine only 1st time ReportName gets downloaded. What if I run my script again and the file downloads? It actually appends (1)  and then next time again (2) and so to the filename. So it becomes ReportName (1).xlsx , ReportName (2).xlsx and so on. So in this scenario above code will fail.


To avoid the above issue, I tried doing this (hoping wildcard character match works):



But it didn't work. It returns false, although the file is downloaded and present in the path.


Please help.

Super Contributor

I can't answer the question as asked having never come across it. As a matter of habit, what I would do in script would be

- do the stuff that generates the download.

- check that the downloaded file exists.

- clean up (delete) the downloaded file.


Thus next run, the file does not have a counter appended to it. 


One option. Hopefully someone can chime in on your question as asked.

The checking for a File existence with a wildcard is a bad practice.

As @vthomeschoolmom  said the right way to do this is to delete the file during each run after exists return true.



Champion Level 3



aqFileSystem.FindFiles() ?


  /Alex [Community Champion]
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
Esteemed Contributor

FindFiles could work.  Then if the array returned has a length greater than 0, at least one file exists.



Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

If this were me, I would not love this check. This check - finding any file that may have been downloaded, does not adaquately consider whether or not what is being found is THIS file from THIS run. Thus the method suggested. ymmv

Showing results for 
Search instead for 
Did you mean: