Skip to content Skip to sidebar Skip to footer

Is It Possible To Check If A File Exists On Disk Using Javascript (not Running In A Browser)?

I am using an app that uses only JavaScript as its scripting language. I have a .ini file and I need to see if it exists. Is this possible? Also, if it doesn't exist, how can I hal

Solution 1:

Ok doing something like this works:

var file = new File(datafile);
var result = file.open ('r');

if result is true, then the file exists, otherwise false means the file does not exist.

Solution 2:

Try this:

var myfile = newFile(myfile_path);

if (!myfile.exists) {
    alert(myfile + " could not be found!");
}

Post a Comment for "Is It Possible To Check If A File Exists On Disk Using Javascript (not Running In A Browser)?"