HELP! IE8 Javascript Filesystemobject fileexists working and not working

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");
if(fsoNew.FileExists('C:\\\\RoyalMailDirectFeed\\\\Result.txt')){
   f1 = fsoNew.OpenTextFile('C:\\\\RoyalMailDirectFeed\\\\Result.txt', ForReading, true);
   while(!f1.AtEndOfStream){
       resultCode = f1.ReadLine();
       resultTrack = f1.ReadLine();
       resultMessage = f1.ReadLine();
   }
   f1.Close();
   fsoNew.DeleteFile('C:\\\\RoyalMailDirectFeed\\\\Result.txt',true);
}


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 reading long descriptions. Any help is welcome

That’s pretty weird…
I’ve never worked with that before, so I’m not sure really what’s going on, but I noticed you’re declaring two fso’s and only using one. Since the script works when you have the alert in there, and that alert happens to be between those two declarations, I wonder if it has something to do with that? Try getting rid of the first fso declaration along with the alert and see what you come up with.

Hi overthemike,

I can assure you that I have tested with only one FSO instance but did not work so I thougth let me give it a try making new instance as well. but same result.

Thanks for reply and hope more members will come forward to help.

Activex objects aren’t dealt with here, primarily because they are supported only on Internet Explorer with Microsoft’s jscript language. Most other web browsers just don’t support activex objects.

You might be able to get some help from Microsoft’s own page about it though.
ActiveXObject Object (Windows Scripting - JScript)