Or, more verbosely, the following function will always report that the file with the filename passed to it exists, even if the file does not.
function checkForFile(fileName) //check to see if file exists
var s = new String(fileName);
f = new File(s, "read");
if (f.isopen) //if succeed in opening file
post("found file: " + fileName + "n");
else //file doesn’t exist
f.close(); //anal retentively close file
post("could not find file: " + fileName + "n");
If I change the string declaration to be like this, however:
var s = new String();
s = filename;
Then it works fine. Don’t pick on programming style, by the way. I know that it is fully unnecessary to declare s in the first place. This was just a concise example. It is not specific to a local function either. If a string is declared with that text outside of the function, the function still misreports the file.
can’t help with an answer,
but can confirm that is happening with me too.
I had struck this the first time i used f.isopen
and had incorrectly thought that it could not be used to check for the existence of files and have been laboriously trawling through folder objects to check for files.
so sorry that i can’t help but thank you for posting this