SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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:

    Code JavaScript:
    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

  2. #2
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  3. #3
    SitePoint Member
    Join Date
    Jul 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    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)
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •