View Full Version : IE8 Javascript Filesystemobject fileexists not working

07-27-2011, 12:00 PM
I am facing weird problem - real weird and do not know how to solve it. I am trying to use filesystemobject in javascript in IE8 ( as xp supports upto ie8 only) - Below is my CODE:

var ForReading = 1, ForWriting = 2, ForAppending = 8;
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0;
var fso = new ActiveXObject("Scripting.FileSystemObject");

alert('C:\\RoyalMailDirectFeed\\Result.txt'); //************** LINE1 **********/
var fsoNew = new ActiveXObject("Scripting.FileSystemObject");
f1 = fsoNew.OpenTextFile('C:\\RoyalMailDirectFeed\\Result.txt', ForReading, true);
resultCode = f1.ReadLine();
resultTrack = f1.ReadLine();
resultMessage = f1.ReadLine();

Check LINE1 - if I put this alert - script works fine fileexists works and so is the rest of the code. If I remove/comment alert in LINE1 - script can not find the fileexists or not....

Same code works fine in IE9 without alertbox. It is driving me crazy.

I have tried putting filepath in variable and using variable instead of providing path itself - the result is same.

FSO usage is allowed in IE8 options settings to run activex objects ( as it works fine with alertbox appearing first )

Thanks for viewing this question.