Reading a directory with FileSObject and JScript

Results 1 to 3 of 3

Thread: Reading a directory with FileSObject and JScript

  1. #1
    Steve Griff Guest

    Default Reading a directory with FileSObject and JScript

    Hi gang. I want to read the contents of a directory.<BR>Here&#039;s the code. What&#039;s wrong with it?<BR><BR>var myTempDir = "c:\upload\";<BR><BR>for(var i = 1; i &#060;= myFileSystem.GetFolder(myTempDir).Files.Count; i = i + 1)<BR>{<BR>var myFilenamez = myFileSystem.GetFolder(myTempDir).Files.Item(i);<B R> <BR> Response.Write(myFilenamez);<BR><BR>}<BR><BR>will this work?<BR><BR>Thanxs<BR><BR>Steve Griff<BR><BR><BR> <BR> Response.Write("It got here");

  2. #2
    Sreedharan Guest

    Default Do you want us to QA your code or...

    .. are you facing some problem? <BR><BR>What is the error you are getting? Also, you have put in only a small bit of code. More info, with details of the error you are getting, will enable others to give solutions.

  3. #3
    Join Date
    Dec 1969

    Default RE: Reading a directory with FileSObject and JScri

    Steve,<BR> I was trying the same style of coding at first. The FileSystemObject "Files" collection isn&#039;t really a collection. You have to enumerate through it. This was something that I hadn&#039;t seen before in JScript (doesn&#039;t look like many people have - I&#039;ve not seen much info about it before).<BR> Try something like this...<BR><BR><BR>var myTempDir = "c:\upload\";<BR>var objTheFiles = myFileSystem.GetFolder(myTempDir).Files;<BR>var enumTheFiles = new Enumerator(objTheFiles);<BR><BR>for(;!enumTheFiles .atEnd();enumTheFiles.moveNext()){<BR> var theItem = enumTheFiles.item();<BR> var myFilenamez = theItem.Name;<BR> Response.Write(myFilenamez);<BR>}<BR><BR><BR>I think that will do it for you.<BR><BR> -- Alex<BR><BR>

Posting Permissions

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