is there a method to detect whether a file is in use?
I open use the files comparison method to see if two files matches. However, sometimes one of the files are in use by my testing application, and I get thrown an error by testcomplete? I have a workaround which i just introduce an arbitrary delay, but i would like to know if there is a way to detect whether a file is in use or not.
RE: is there a method to detect whether a file is in use?
I don't know of a particular method to determine if a file is in use or not. However, what you could do is try and open the file and trap an exception using aqFile.OpenTextFile such as the following DelphiScript code.
function FileInUse(FilePath): Boolean;
If the file is in use, an exception is raised resulting in the function returning
true. If not, the file is attempted to be closed and the result of the function
is set to the opposite of whether or not the file was able to be closed
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.