当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP FileSystem

ASP
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP Quick Ref
ASP 摘要
ASP 实例

ASP FileSystem


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 814 ::
收藏到网摘: n/a

The FileSystemObject object is used to access the file system on the server.
FileSystemObject对象是用来访问服务器端的文件系统的


Examples
举例

Does a specified file exist?
查看指定的文件是否存在?
This example demonstrates how to first create a FileSystemObject Object, and then use the FileExists method to check if the file exists.
这个例子告诉我们如何第一次建立FileSystemObject对象,以及如何使用FileExists方法来检查文件是否存在。

Does a specified folder exist?
查看一个指定的文件夹是否存在?
This example demonstrates how to use the FolderExists method to check if a folder exists.
这个例子告诉我们如何使用FolderExists方法检查一个文件夹是否存在。

Does a specified drive exist?
查看一个指定的驱动器是否存在
This example demonstrates how to use the DriveExists method to check if a drive exists.
这个例子告诉我们如何使用DriveExists方法检查一个驱动器是否存在。

Get the name of a specified drive
获取指定驱动器的名称
This example demonstrates how to use the GetDriveName method to get the name of a specified drive.
这个例子告诉我们如何通过GetDriveName方法获取指定驱动器的名称。

Get the name of the parent folder of a specified path
获取指定路径中父文件夹的名称
This example demonstrates how to use the GetParentFolderName method to get the name of the parent folder of a specified path.
这个例子告诉我们如何通过GetParentFolderName方法获取指定路径中父文件夹的名称。

Get the file extension
获取文件的扩展名
This example demonstrates how to use the GetExtensionName method to get the file extension of the last component in a specified path.
这个例子告诉我们如何通过GetExtensionName方法获取指定路径中文件的扩展名。

Get file name
获取文件名
This example demonstrates how to use the GetFileName method to get the file name of the last component in a specified path.
这个例子告诉我们如何通过GetFileName方法获取指定路径中的文件名。

Get the base name of a file or folder
获取一个底层文件或文件夹的名称
This example demonstrates how to use the GetBaseName method to return the base name of the file or folder, in a specified path.
 这个例子告诉我们如何通过GetBaseName方法获取指定路径下的一个底层文件或文件夹的名称。


The FileSystemObject Object
FileSystemObject对象

The FileSystemObject object is used to access the file system on the server. This object can manipulate files, folders, and directory paths. It is also possible to retrieve file system information with this object.
FileSystemObject对象是用来访问服务器端的文件系统的。它可以使用文件、文件夹以及目录的路径;它也可以获取系统信息。

The following code creates a text file (c:test.txt) and then writes some text to the file:
下面的代码建立了一个文本文件(c:test.txt)并在文件内写入了文字:

<%
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:test.txt",true)
fname.WriteLine("Hello World!")
fname.Close
set fname=nothing
set fs=nothing
%>


The FileSystemObject object's properties and methods are described below:
FileSystemObject对象的具体属性和方法描述如下:

Properties
属性

Property
属性
Description
描述
Drives Returns a collection of all Drive objects on the computer
返回所有驱动器对象集

Methods
方法

Method
方法
Description
描述
BuildPath Appends a name to an existing path
向现有的路径中追加一个名称
CopyFile Copies one or more files from one location to another
将本地计算机中的一个或多个文件复制到其他计算机
CopyFolder Copies one or more folders from one location to another
将本地计算机中的一个或多个文件夹复制到其他计算机
CreateFolder Creates a new folder
建立一个新的文件夹
CreateTextFile Creates a text file and returns a TextStream object that can be used to read from, or write to the file
建立一个文本文件,返回一个能从该文件读取或写入信息的文本流对象
DeleteFile Deletes one or more specified files
删除一个或多个指定文件
DeleteFolder Deletes one or more specified folders
删除一个或多个指定文件夹
DriveExists Checks if a specified drive exists
检查指定的驱动器是否存在
FileExists Checks if a specified file exists
检查指定的文件是否存在
FolderExists Checks if a specified folder exists
检查指定的文件夹是否存在
GetAbsolutePathName Returns the complete path from the root of the drive for the specified path
返回某个指定路径从驱动器根目录开始的完整路径
GetBaseName Returns the base name of a specified file or folder
返回底部文件或文件夹的名称
GetDrive Returns a Drive object corresponding to the drive in a specified path
返回与指定路径相对应的一个驱动器对象
GetDriveName Returns the drive name of a specified path
返回指定路径下的驱动器名称
GetExtensionName Returns the file extension name for the last component in a specified path
返回指定路径下文件的扩展名
GetFile Returns a File object for a specified path
获取指定路径下的文件对象
GetFileName Returns the file name or folder name for the last component in a specified path
返回指定路径下的文件名或文件夹名
GetFolder Returns a Folder object for a specified path
返回指定路径下的文件夹对象
GetParentFolderName Returns the name of the parent folder of the last component in a specified path
返回指定路径下的父文件夹的名称
GetSpecialFolder Returns the path to some of Windows' special folders
返回某些Windows专用文件夹的路径
GetTempName Returns a randomly generated temporary file or folder
返回一个随机产生的临时文件或文件夹
MoveFile Moves one or more files from one location to another
将本地计算机上的一个或多个文件移动到异地计算机上
MoveFolder Moves one or more folders from one location to another
将本地计算机上的一个或多个文件夹移动到异地计算机上
OpenTextFile Opens a file and returns a TextStream object that can be used to access the file
打开一个文件,同时返回一个能够访问这个文件的文本流对象

评论 (0) All

登陆 | 还没注册?