What is FSO?
FSO is a file system object. It is a technology used to list windows disk directories and files and delete, create, copy, cut, and move directories and files. Benefits of using the FSO Website: directly read files and subdirectories under the directory for easy maintenance. If you need to add any content, place the files under the corresponding directory. The FSO website is similar to the Windows operation interface, it is easy to use and windows will use the FSO website.
Imagine that it is very convenient to make files and folders on your hard disk into a website and update the content as long as they are added to the directory in the future? In this way, new users with no experience can build their own websites.
Reference: http://dwdesign.vicp.net
Or http://dwdesign.dns0755.net
FSO *, with the same directory and file
Atendofline *
If the file pointer is located just before the row mark in the textstream file, true is returned; if not, false is returned.
Atendofstream *
If the file pointer is at the end of the textstream file, true is returned. If not, false is returned.
Attributes owner *
Sets or returns the attributes of a file or folder.
Availablespace *
Returns the size of the space available to users on the specified drive or network share.
Column *
Returns the column number of the current character position in the textstream file.
Comparemode *
Sets and returns the comparison mode to compare string keywords in a dictionary object.
Count *
Returns the number of items in a collection or dictionary object.
Datecreated *
Returns the creation date and time of the specified file or folder. Read-only.
Datelastaccessed *
Returns the last accessed date and time of the specified file or folder.
Datelastmodified *
Returns the Last modified Date and time of the specified file or folder.
Drive *
Returns the drive letter of the drive where the specified file or folder is located.
Driveletter *
Returns the drive letter shared by the local physical drive or network.
Drives *
Returns a drives set that contains all available drive objects on the local computer.
Drivetype *
Returns a value indicating the type of the specified drive.
Files *
Returns a file set that contains all file objects in the specified folder, including objects set to hidden and system file attributes.
Filesystem *
Returns the type of the file system used by the specified drive.
Freespace *
Returns the size of the space available to users on the specified drive or network share.
Isready *
If the specified drive is ready, true is returned. If not, false is returned.
Isrootfolder *
If the specified folder is the root folder, true is returned. If not, false is returned.
Item *
Set or return the corresponding project for the specified keyword in the dictionary object. For a set, a project is returned Based on the specified keyword.
Key owner *
Set keywords in the dictionary object.
Line *
Returns the current row number in the textstream file.
Name *
Sets or returns the name of the specified file or folder.
Parentfolder *
Returns the folder object at the upper level of a specified file or folder.
Path *
Returns the path of the specified file, folder, or drive.
Rootfolder *
Returns a folder object that represents the root folder of the specified drive.
Serialnumber *
Returns the decimal serial number that uniquely identifies a disk volume.
Sharename *
Returns the Network Share Name of the specified drive.
Shortname *
Return the short name used by the program that requires the early 8.3 naming convention.
Shortpath *
Return the short path used by the program that requires the early 8.3 naming convention.
Size owner *
Returns the size of the specified file, in bytes. For folders, the size of all files and subfolders in the folder is returned, in bytes.
Subfolders *
Returns a folders set that contains all the folders in the specified folder, including those that are set as hidden and system file attributes.
Totalsize *
Returns the total space shared by the drive or network, in bytes.
Type *
Returns information about the file or folder type.
Volumename *
Sets or returns the volume name of the specified drive.
Method or owner * description
Buildpath () to generate a file path
Copy file ()
Copyfolder () Copy directory
Createfolder () create a new directory
Createtextfile () to generate a file
Deletefile () deletes an object.
Deletefolder () deletes a directory
Driveexists () checks whether the drive letter exists
Drives returns a collection of drive letters.
Fileexists () checks whether a file exists
Folderexists checks whether a directory exists
Getabsolutepathname () gets the absolute path of a file
Getbasename () Get the file name
Getdrive () gets the drive letter name
Getdrivename () gets the drive letter name
Getextensionname () gets the file suffix
GetFile () generate a file object
Getfilename () Get the file name
Getfolder () to get the directory object
Getparentfoldername: Get the parent directory name of the file or directory
Getspecialfolder () Get the special directory name
Gettempname () generates a temporary file object
Movefile () Move a file
Movefolder () Move directory
Opentextfile () open a file stream
Instance description FSO usage
Buildpath (path, file name) // This method will add a file to the specified path and automatically add the delimiter
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
VaR newpath = FSO. buildpath ("C: // tmp", "51js.txt"); // generate the path of C:/tmp/51js.txt
Alert (newpath );
-->
</SCRIPT>
Copyfile (source file, target file, overwrite) // copy the source file to the target file. When the overwrite value is true, if the target file exists, the file will be overwritten.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
VaR newpath = FSO. copyfile ("C: // autoexec. Bat", "d: // autoexec. Bak ");
-->
</SCRIPT>
Http://www.xker.com
Copyfolder (Object directory, target directory, overwrite) // copy the object directory to the target directory. If it is set to true, the file will be overwritten if the target directory exists.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
FSO. copyfolder ("C: // windows // desktop", "d: //"); // copy the desktop directory of drive C to the root directory of drive D.
-->
</SCRIPT>
Createfolder (directory name) // create a new directory
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
VaR newfoldername = FSO. createfolder ("C: // 51js"); // create a 51js directory on drive C
-->
</SCRIPT>
Createtextfile (file name, overwrite) // create a new file. If the file already exists, set the overwrite value to true.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
VaR newfileobject = FSO. createtextfile ("C: // autoexec51js. Bat", true); // The Script creates a file named autoexec51js. bat on drive C.
-->
</SCRIPT>
Deletefile (file name, read-only ?) // Delete an object. If the object attribute is read-only, set the read-only value to true.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject"); // to ensure security, I first back up autoexec. BAT to your D disk.
VaR newpath = FSO. copyfile ("C: // autoexec. Bat", "d: // autoexec. Bat"); // Delete the autoexec. BAT file of drive C.
FSO. deletefile ("C: // autoexec. Bat", true );
-->
</SCRIPT>
Deletefolder (file name, read-only ?) // Delete a directory. If the Directory attribute is read-only, set the read-only value to true.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
FSO. copyfolder ("C: // windows // desktop", "d: //"); // to ensure security, copy the desktop directory of your drive C to the root directory of your drive D.
FSO. deletefolder ("C: // windows // desktop", true); // delete your desktop directory. However, because desktop is a system item, you cannot delete it all, but .........
-->
</SCRIPT>
Driveexists (drive letter) // check whether a disk exists. If it exists, it returns true. If it does not exist, it returns .......
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Hasdrived = FSO. driveexists ("D"); // check whether the system has a d Disk
Hasdrivez = FSO. driveexists ("Z"); // check whether the system has a Z Disk
If (hasdrived) Alert ("your system has a ddisk ");
If (! Hasdrivez) Alert ("your system has no Z disk ");
-->
</SCRIPT>
Fileexists (File Name) // check whether a file exists. If it exists, it returns true. If it does not exist, it returns .......
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Filename = FSO. fileexists ("C: // autoexec. Bat ");
If (filename) Alert ("You have an autoexec. BAT file in drive C. Press OK and the file will be deleted! "); // Joke :)
-->
</SCRIPT>
Folderexists (directory name) // check whether a directory exists. If it exists, it returns true. If it does not exist, it returns .......
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Foldername = FSO. folderexists ("C: // windows // fonts ");
If (Foldername) Alert ("after you press OK, the font of the system will be deleted! "); // Joke :)
-->
</SCRIPT>
Getabsolutepathname (file object) // returns the absolute path of the file object in the system.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Pathname = FSO. getabsolutepathname ("C: // autoexec. Bat ");
Alert (pathname );
-->
</SCRIPT>
Getbasename (file object) // returns the file name of the object.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Basename = FSO. getbasename ("C: // autoexec. Bat"); // get the autoexec. BAT file name Autoexec
Alert (basename );
-->
</SCRIPT>
Getextensionname (file object) // file suffix
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Exname = FSO. getextensionname ("C: // autoexec. Bat"); // obtain the autoexec. Bat suffix
Alert (exname );
-->
</SCRIPT>
Getparentfoldername (file object) // get the parent directory name
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Parentname = FSO. getparentfoldername ("C: // autoexec. Bat"); // obtain the parent directory c of autoexec. bat.
Alert (parentname );
-->
</SCRIPT>
Getspecialfolder (directory code) // obtain the path of some special directories in the system. The directory code has three directories: 0: the directory where the window is installed; 1: The system file directory; 2: the temporary file directory.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Tmpfolder = FSO. getspecialfolder (2); // obtain the path of the temporary system file directory. For example, if my path is C:/Windows/temp
Alert (tmpfolder );
-->
</SCRIPT>
Gettempname () // generate a random temporary file object. The random number is followed by a random number using rad, as if some software will generate *. tmp during installation.
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
Tmpname = FSO. gettempname (); // I generated raddb70e. tmp during the test.
Alert (tmpname );
-->
</SCRIPT>
Movefile (source file, target file) // move the source file to the location of the target file
<Script language = "JavaScript">
<! --
VaR FSO = new activexobject ("scripting. FileSystemObject ");
VaR newpath = FSO. movefile ("C: // autoexec. Bat", "d: // autoexec. Bat"); // move the autoexec. BAT file of drive C to drive D.
-->
</SCRIPT>