ASP Getting Started Tutorial-File system Object model

Source: Internet
Author: User

1. File System Object Model

The FileSystemObject object model includes several objects that can be used to create, adapt, move, and delete folders or files, as well as to obtain various information about a folder or file. The FileSystemObject object model contains objects as shown in the following table:

Objects < tables in the FileSystemObject object model >
Object Description/Grammar Format/comment
FileSystemObject Primary object that provides a complete set of methods for creating, deleting, gathering related information, and generally manipulating drives, folders, and files.
Set fso=server.createobject ("Scripting.FileSystemObject")
The FSO parameter is a required parameter and should be a Filesystemobjce instance object name.
Drive Allows you to collect information about the drives used by the system, such as how much free space is driven, what the share name is, and so on.
Fso. Getdrive (Path)
The FSO parameter is a required parameter and should be a Filesystemobjce instance object name, path can be a drive letter (such as C), a drive letter with a colon (c:), a drive letter with a colon and a path delimiter (c:), or any specified network share, such as (\ Computer2share2).
Folder Allows you to create, delete, or move folders, and query the system for the name, path, and so on.
Fso. CreateFolder (FolderName)
The parameter FSO specifies the name of the Filesysobject object. FolderName is a string expression that specifies the folder you want to create.
Files Allows you to create, delete, or move files, and query the system for the name, path, etc. of the file.
Fso. GetFile (filespec)
The parameter FSO specifies the name of the Filesysobject object. FILESPEC Specifies the path (absolute or relative) of the file.
Teststream Allow reading and writing of text files.
Fso. CreateTextFile (filename [, overwrite [, Unicode]])
The parameter FSO specifies the name of the Filesysobject or Folder object. Filername is a string expression that specifies the file to create. Overwrite is an optional parameter that takes a Boolean value indicating whether an existing file can be overwritten. Unicode is also an optional parameter, a Boolean value that indicates whether a file is created in Unicode or ASCII file format, and if this value is true, the file is created in Unicode file format, or if the value is False or omitted, the file is created in ASCII file format.
Note:

You must first create a file system object (FileSystemObject) before creating any objects in the FileSystemObject object model.

2, the method of FileSystemObject object

You can use the FileSystemObject object method to access files and folders on a WEB server, and the syntax format and description for the method are shown in table two.

Methods of FileSystemObject Objects < table two >

Method Description
Buildpaty (Path,name) After you add Name to path, the path symbol (), such as Objfso.buildpath (Server.MapPath ("F"), "a.asp") is automatically corrected when necessary to return the c:inetpubwwwrootfa.asp path.
Copyfile.source.destination,overwrite Copies the file specified by Source to destination, and if the Overwrite value is True, overwrites the destination file with the same name.
CopyFolder Source,destination,oerwrite Copies the folder specified by Source to destination, and if the Overwrite value is True, a folder with the same name as destination is overwritten.
CreateFolder (Foldermane) Creates a Foldermane folder and returns an instance of a Folder object.
CreateText (Filename,overwrite,unicode) Creates a text file named filename, and returns an instance of the TextStream object. Overwrite is a Boolean value that, if true, indicates that it can be overridden, otherwise it is not overwritten, the default value is Flase,unicode Boolean, and if true, it is represented as a Unicode text file, otherwise it is an ASCII text file, and the default value is False.
DeleteFile Path,force Deletes the file specified by Path, Force is a Boolean, and if the value is true, deletes the read-only file, the default value is Flase (no read-only files are deleted).
DeleteFolder Path,force Deletes the folder specified by Path, Force is a Boolean, and if the value is true, deletes the read-only folder, and the default value is False (do not delete the read-only folders).
Driveexists (Paty) Returns TRUE if the disk specified by Path exists, otherwise returns FALSE.
FileExists (Path) Returns True if the file specified by Path exists, otherwise returns FALSE.
FolderExists (Path) Returns True if the folder specified by Path exists, otherwise returns FALSE.
Getdrive (Path) Returns the disk containing Path with the return value of a Drive object instance.
GetDriveName (Path) Returns the name of the disk that contains Path, and the return value is a string.
Getextensionname (Path) Returns the extension of the file specified by Path, and the return value is a string.
GetFile (Path) Returns the file specified by Path, which returns a value of one instance of the file object.
GetFileName (Path) Returns the file name or folder name at the back of the Path.
GetFolder (Path) Returns the folder specified by Path, and the return value is an instance of a Folder object.
Getparentfoldername (Path) Returns the name of the Path's parent folder, with the return value being a string.
GetSpecialFolder (Name) Returns the path to a special folder, which can be windowsfolder, Systemfolder, or Temporaryfolder, representing the Windows folder, the System folder, and the folder where the temporary files are stored.
MoveFile source,destination Moves the file specified by Source to destination.
MoveFolder source,destination Moves the folder specified by Source to destination.
OpenTextFile (Filename,iomode,create,format) Opens the Filenaem-specified text file and returns a TextStream object instance, IOMode the way the text file is opened, 1 is read-only, 2 is writable, and 3 is appended to the back; create indicates whether the text file is to be created when it does not exist; In the format of a text file, 1 represents a Unicode text file, 0 represents an ASCII text file, and-2 indicates a system default value.
See the full set of ASP Getting started tutorials

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.