Show an directory contence in Javascript

Results 1 to 2 of 2

Thread: Show an directory contence in Javascript

  1. #1
    Join Date
    Dec 1969
    Posts
    6

    Default Show an directory contence in Javascript

    Hello . <BR>I&#039m using Javascript as my default ASP language. I want to show the contence of an directory whit use of the FileSystemObject but I&#039m not able to do this and I don&#039t understand why not The ode is included below. It just won&#039t start the loop where I show the files. I&#039ve seen many examples in VBScript But ...<BR><BR>Thanks Mark Nijhof Please Reply to mark@nijhof.com<BR><BR>&#060;%@ Language="JScript" %&#062;<BR>&#060;% Response.Expires=-1441; %&#062;<BR>&#060;%<BR>folderspec = "/";<BR> var fs, f, f1, fc, s;<BR> fs = new ActiveXObject("Scripting.FileSystemObject");<BR> f = fs.GetFolder(folderspec);<BR> fc = f.Files;<BR> s = "hallo ";<BR> for (f1 in fc)<BR> {<BR> Response.Write(f1.name+"<BR>");<BR> }<BR>%&#062;<BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    2,849

    Default RE: Show an directory contence in Javascript

    This doesn&#039t work because JScript doesn&#039t have an "in" keyword. You can&#039t say:<BR><BR>for (f1 in fc)<BR><BR>What you&#039ve got to do is loop through fc.Count<BR><BR>for (int i=0; i &#060; fc.Count; i++)<BR>Response.Write fc[i];<BR><BR>This is untest code; I don&#039t use JScript, and I don&#039t know if this will work or not. I know that your syntax, though, is incorrect, and the syntax above is correct. However, I am not sure if JScript supports this. Is there any reason why you chose to use JScript over VBScript?

Posting Permissions

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