
Introduction
Maybe you want to have list of server or client files in your web page
to uploading or downloading or changing . JScript allow you to do this. You can
capture all files type , size , properties in all directories and use them
easily. In this sample I use this technique for searching files in local hard drive.
Necessary Attention: your browser should have access to run ActiveX
objects. If receive a error message telling "Automatic Server Can't Create Object"
you most go to Internet Option and in security tab select custom level in Local
part and change options to get effect.
ActiveX Objects
For working with Files and directory you should make a server object as
Scripting.FileSystemObject
then with GetDirectory()
method can get a directory
object. If you want know the directory is use FolderExists()
.
var Fo = new ActiveXObject("Scripting.FileSystemObject");
Enumerator
Enumerators are an array of Directory or File objects such that you can use methods to get special file or sub directory that are in
defined path. Enumerator have some methods I have called like atEnd()
and moveNext()
in my sample.
function FindFile(FOo)
{
var FSo = new Enumerator(FOo.Files);
for (i=0;!FSo.atEnd();FSo.moveNext())
...
}
Files Object Properties
For getting a object that is in Enumerator object you must use item()
and it
returns a file or directory object that are in current place of Enumerator.
Then you can use Files properties that are listed.
Attributes
DateCreated
DateLastAccessed
DateLastModified
Drive
Name
ParentFolder
Path
ShortName
ShortPath
Size
Type
FSo.item().name FSo.item().type FSo.item().size