
performance of FileSystem-object
Thanks for your reply Steve.
Actually what I'm doing is exactly what you proposed.
I'm gathering information by storing it into an array;
But the lack of performance is due to the filesystemobject,
occuring when accessing the File-object.
So if I change my code to:
###
for (; !fc.atEnd(); fc.moveNext())
s[s.length] = fc.item(); <--- just getting File-Object
}
###
That's very fast.
But:
###
for (; !fc.atEnd(); fc.moveNext())
s[s.length] = fc.item().Name; <--- accessing the File-Object
Quote:
}
###
This results in poor perfomance.
I guess JScript is really accessing each file
in the second case.
What I need is just names and sizes of files;
I don't need any further information.
Any idea how to do that - maybe without filesystemobject ?
Maybe some ActiveX-Object that could do that ?
best regards,
Michael Wender
Quote:
> You're always going to take a performance hit accessing files over a
> network. Not too sure what you can do about that.
> But your biggest hit is coming from string manipulation. Every time you
> append to a string, JScript has to make a completely new string and destroy
> the old one. Your loop appends to the string twice! Changing it to append
> only once speeds up the loop by a factor of two (surprise!).
> for (; !fc.atEnd(); fc.moveNext())
> {
> s += fc.item()+"<br>";
> }
> But for real time savings, don't manipulate strings inside a loop! Array
> manipulation is relatively cheap.
> s = new Array();
> for (; !fc.atEnd(); fc.moveNext())
> {
> s[s.length] = fc.item();
> }
> s = s.join("<br>");
> =-=-=
> Steve
> -=-=-
> > I'm using FileSystem.object to display all files and subfolders
> > of a certain folder on the client maschine.
> > Code is executed inside an .hta.
> > This works fine with few local files, but gets
> > extremly slow when accessing folders with more than
> > 500 files or folders on LAN-network drives.
> > This is the code I use: (it's copied from msdn):
> > function ShowFolderFileList(folderspec)
> > {
> > var fso, f, f1, fc, s;
> > fso = new ActiveXObject("Scripting.FileSystemObject");
> > f = fso.GetFolder(folderspec);
> > fc = new Enumerator(f.files);
> > s = "";
> > for (; !fc.atEnd(); fc.moveNext())
> > {
> > s += fc.item();
> > s += "<br>";