earriaga
12 years agoOccasional Contributor
TC9 Deleting Text Files
I know this is fairly easy and just switch to TC9 from TC7. I have a batch file that its purpose is to create a text file & write something like "PASS". Now my code gets this file and the first thing it does is deletes the file using the "aqFileSystem["DeleteFile"](AFileName)" no problem. Now my batch file is only executable if it senses a LED ON (using a camera as a sensor) and I then use this function to read what is inside the text file:
ReturnFileLine(Location){ TextFile,Content;
At the end of the script I would like to delete this text file and start the function all over again (the script is inside a for loop), but I get this message that does not allow me to delete this file:
"The process cannot access the file because it is being used by another process.
Path: C:\AFileName.txt"
I have tried renaming the file and moving it, but still get the same message as above. Is there a way that I can stop this process so I can delete this file or other ways that I can go around this issue, such as a force delete of some kind. Also, this may seem like a stupid question,but how do I find out what the process is that it is talking about?
Thanks!
PS: sorry for the bad english
function ReturnFileLine(Location){
var TextFile,Content;
ReturnFileLine(Location){ TextFile,Content;
TextFile = aqFile["OpenTextFile"](Location, aqFile["faRead"], aqFile["ctANSI"]);
TextFile.Cursor = 0;
while(! TextFile["IsEndOfFile"]()){
Content=TextFile["ReadLine"]();
Log["Message"](Content);}
while(TextFile["Exists"])
TextFile["Close"]();
return Content;
}
At the end of the script I would like to delete this text file and start the function all over again (the script is inside a for loop), but I get this message that does not allow me to delete this file:
"The process cannot access the file because it is being used by another process.
Path: C:\AFileName.txt"
I have tried renaming the file and moving it, but still get the same message as above. Is there a way that I can stop this process so I can delete this file or other ways that I can go around this issue, such as a force delete of some kind. Also, this may seem like a stupid question,but how do I find out what the process is that it is talking about?
Thanks!
PS: sorry for the bad english