ASP 3.0 Advanced Programming (20)

Source: Internet
Author: User
Tags object contains end include relative
Programming | Advanced 5.4.1 FileSystemObject Object Member Overview
The FileSystemObject object provides a property and a series of methods that can be used to manipulate some subordinate objects implemented by the FileSystemObject object. This provides a complete overview of the content and then describes each subordinate object.
1. Properties of FileSystemObject
The FileSystemObject object has only one property, which is used to get a list of all the valid drives on the current machine, as shown in table 5-4:
Table 5-4 Properties and descriptions of FileSystemObject objects
Property
Description

Drivers
Returns the list of drives available for the local computer.

2. The method of FileSystemObject
The FileSystemObject object provides a series of methods for using dependent objects, including objects such as drive, folder, and file. It also implements two methods for TextStream objects: CreateTextFile and OpenTextFile. The method is divided into three classes, depending on the type of object being used.
(1) The method associated with the drive
The drive-related methods are shown in table 5-5:
Table 5-5 methods and instructions related to drives
Method
Description

Driveexists (DRIVESPEC)
Returns true if the drive specified in Drivespec exists, otherwise returns false. The Drivespec parameter can be a drive letter, or a full absolute path to a file or folder

Getdrive (DRIVESPEC)
Returns the drive object that corresponds to the drive specified by Drivespec. Drivespec can contain colons, path separators, or network share names, namely: "C", "C:", "C:\" and "\\machine\sharename"

GetDriveName (DRIVESPEC)
Returns the name of the drive specified by the Drivespec with a string. The Drivespec parameter must be an absolute path to a file or folder, or just a drive letter, such as: "C:" or "C"

(2) Folder-related methods
The folder-related methods are shown in table 5-6:
Table 5-6 methods and descriptions related to folders
Method
Description

BuildPath (Path,name)
Add a file or folder named name to the path you already have, and add the path separator ' \ ' if needed.

CopyFolder (Source,destination,overwrite)
Copies one or more folders from the specified source folder, which can contain wildcards, to the specified destination folder destination, including all files in the source folder. If source contains a wildcard or a path delimiter (' \ ') at the end of the destination, destination is considered to be the folder where the copy of the source folder is to be placed. Otherwise, consider destination to be the pathname of the new folder you want to create. If the destination folder already exists and the overwrite parameter is set to False, an error occurs and the default overwrite parameter is True

CreateFolder (FolderName)
Create a folder with a path name of FolderName. If FolderName already exists, an error is generated

DeleteFolder (Folderspec,force)
Deletes one or more folders that are specified by Folderspec (which can contain wildcard characters in the last part of the path) and all content in the folder. If the optional force parameter is set to True, the folder will be deleted even if it contains files that have read-only properties. The default force parameter is False

Folderexist (FOLDERSPEC)
Returns true if the folder specified by Folderspec is present, otherwise it returns false. The Folderspec parameter can contain the absolute or relative path of the folder, or just the name of the folder you see in the current folder

Getabsolutepathname (PATHSPEC)
Returns the path to an explicitly specified folder, taking into account the path to the current folder. For example, if the current folder is "C:\docs\sales\" and the Pathspec is "out of the box", the character returned is "C:\docs\sales\jan". Wildcard characters, "..." and "\" path operators are acceptable

GetFolder (FOLDERSPEC)
Returns the Folder object that corresponds to the specified folderspec. Folderspec can be the relative or absolute path of a folder

Getparentfoldername (PATHSPEC)
Returns the folder on the Pathspec file or folder. Do not verify that the folder exists

GetSpecialFolder (FOLDERSPEC)
Returns a Folder object that corresponds to a specific Windows directory. The allowable values for parameter folderspec are Windowsfolder (0), Systemfolder (1), and Temporaryfolder (2)

MoveFolder (source,destination)
Moves one or more of the folders specified by source to the folder specified by destination. You can include wildcard characters in source, but not in destination. If source contains a wildcard or a path delimiter (' \ ') at the end of the destination, destination is considered the full path and name of a new folder if it is the folder where the source folder is to be placed. An error occurs if the destination folder destination already exists

(3) Documentation-related methods
The file-related methods are shown in table 5-7:
Method
Description

CopyFile (Source,destination,
Overwrite
Copies one or more of the files specified by source (which can contain wildcards) to the specified destination folder destination. If source contains wildcard characters or the destination end is a path delimiter (' \ '), then destination is considered a folder. Otherwise consider destination as the full path and name of a new file. If the destination folder already exists and the overwrite parameter is set to False, an error occurs. The default overwrite parameter is True

CreateTextFile (Filename,overwrite,
Unicode
Creates a new text file on disk with the specified filename filename and returns its corresponding TextStream object, overwriting an existing file of the same name under the same path if the optional overwrite parameter is set to True. The default overwrite parameter is False. If the optional Unicode parameter is set to True, the contents of the file are stored as Unicode text, and the default Unicode parameter is False

Delefile (Filespec,force)
Deletes one or more files specified by filespec (you can include wildcard characters in the last part of the path). If the optional force parameter is set to True, the file with read-only properties is also deleted. The default force parameter is False

FileExists (filespec)
Returns true if the file specified by filespec exists, otherwise it returns false. The filespec parameter can contain the absolute or relative path of the file, or the file name in the current folder

Getbasename (filespec)
Returns the name of the file specified by filespec, which contains the file path but removes the file extension

Getextensionname (filespec)
Returns the extension of the file specified by filespec

GetFile (filespec)
Returns the file object that corresponds to the specified filespec. You can specify a relative or absolute path to a file

GetFileName (PATHSPEC)
Returns the path or file name of the file specified by Pathspec, and returns the last folder name if there is no file name. Do not check whether the file or folder exists

GetTempName ()
Returns a randomly generated file name for the temporary files or folders needed to complete the operation

MoveFile (source,destination)
that specifies the source of the



Related Article

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.