I am trying to delete a file (CS5), if it exists, but I am getting an error saying "txtFile is undefined". The file does exists, but what am I doing wrong? The curDoc variables are all defined and I know it creates txtFile fine because I can write to it later. I just need to delete it if it exists.:
Code: Select all var fileName = curDoc.path+"/" + curFName + ".txt";
var txtFile = new File(fileName);
if(txtFile.exists)
txfFile.remove();
How do I delete a file?
How do I delete a file?
I don't see anything wrong with the code you posted. And if I define curDoc and curFName it runs for me without errors.
Variables are case sensitive. You may want to check that it is not referneced as txtFIle( a common mistake for me ) or something similar in your full code.
Variables are case sensitive. You may want to check that it is not referneced as txtFIle( a common mistake for me ) or something similar in your full code.