Web Analytics Made Easy -
StatCounter FileSystemObject Files iteration in Javasctipt - CodingForum

Announcement

Collapse
No announcement yet.

FileSystemObject Files iteration in Javasctipt

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FileSystemObject Files iteration in Javasctipt

    Ok I have created a FileSystemObject and successfully retrieved the folder I want using GetFolder().

    However I cannot iterate through the .Files collection using JavaScript (not JScript). Has anyone done this??? Help!!!

    Here is my code:

    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
    <%
    var strAppFolder = new String(Server.MapPath("index.asp"));
    var fso = Server.CreateObject("Scripting.FileSystemObject");
    var fldAppFolder;

    //Get the site root folder
    strAppFolder = strAppFolder.substr(0, strAppFolder.search(/index.asp/gi));

    strAppFolder += "applications";


    //Check if the applications folder exists
    if(fso.FolderExists(strAppFolder) == false) {
    fso.CreateFolder(strAppFolder);
    }

    fldAppFolder = fso.GetFolder(strAppFolder);
    %>

    <%
    var fileList = new Array(fldAppFolder.Files);

    for(i=0;i<fileList.Count;i++)
    Response.Write(fileList[i].Item());
    %>

    I know I am supposed to supply a key to the .Item() property but how the heck am I supposed to know what the key is? I just want to get a darn file listing.

  • #2
    Client-side Javascript has the for...in loop which is the counterpart of For...Each loop of vbscript. So I think that will also work in server-side Javascript.

    var f;
    for (f in fldAppFolder.Files){
    Response.Write(f.Name() + "<br />");
    }
    Glenn
    vBulletin Mods That Rock!

    Comment

    Working...
    X