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

ASP
ASP 介绍
ASP Install
ASP 语法
ASP 变量
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream

ASP File


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

The File object is used to return information about a specified file.
File(文件)对象是用来返回指定文件的信息的。


Examples
举例

When was the file created?
什么时候文件建立?
This example demonstrates how to first create a FileSystemObject object, and then use the DateCreated property of the File object to get the date and time a specified file was created.
这个例子告诉我们如何首先建立一个FileSystemObject对象,以及使用File对象中的DateCreated属性获取指定文件建立的日期和时间

When was the file last modified?
什么时候文件被最后修改?
This example demonstrates how to use the DateLastModified property to get the date and time a specified file was last modified.
这个例子告诉我们如何使用DateLastModified属性获取指定文件被最后修改的日期和时间。

When was the file last accessed?
什么时候文件被最后访问?
This example demonstrates how to use the DateLastAccessed property to get the date and time a specified file was last accessed.
这个例子告诉我们如何使用DateLastAccessed属性获取文件被最后访问的时间。

Return the attributes of a specified file
返回指定文件的属性
This example demonstrates how to use the Attributes property to return the attributes of a specified file.
这个例子告诉我们如何使用Attributes属性返回指定文件的属性。


The File Object
File(文件)对象

The File object is used to return information about a specified file.
文件对象是用来返回指定文件的信息的。

To work with the properties and methods of the File object, you will have to create an instance of the File object through the FileSystemObject object. First; create a FileSystemObject object and then instantiate the File object through the GetFile method of the FileSystemObject object or through the Files property of the Folder object.
通过运用文件对象的属性和方法,首先,你必须通过FileSystemObject对象建立一个文件对象的实体;通过FileSystemObject对象的GetFile方法或通过文件对象的Files属性建立一个FileSystemObject对象以及列出一个文件的对象。

The following code uses the GetFile method of the FileSystemObject object to instantiate the File object and the DateCreated property to return the date when the specified file was created:
下面的代码通过使用FileSystemObject对象的GetFile用法列出了文件对象,通过使用DateCreated属性返回了指定文件被创立的时间。

<%
Dim fs,f
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile("c:test.txt")
Response.Write("File created: " & f.DateCreated)
set f=nothing
set fs=nothing
%>

Output:

File created: 9/19/2001 10:01:19 AM

The File object's properties and methods are described below:
File对象的属性和用法如下表列出:

Properties
属性

Property
属性
Description
描述
Attributes Sets or returns the attributes of a specified file
设置或返回指定文件的属性
DateCreated Returns the date and time when a specified file was created
返回指定文件建立的日期和时间
DateLastAccessed Returns the date and time when a specified file was last accessed
返回指定文件最后被访问的日期和时间
DateLastModified Returns the date and time when a specified file was last modified
返回指定文件最后被修改的日期和时间
Drive Returns the drive letter of the drive where a specified file or folder resides
返回指定文件或文件夹所处的盘符的盘符号
Name Sets or returns the name of a specified file
设置或返回指定文件的名字
ParentFolder Returns the folder object for the parent of the specified file
返回指定文件的父文件夹
Path Returns the path for a specified file
返回一个指定文件的路径
ShortName Returns the short name of a specified file (the 8.3 naming convention)
返回一个指定文件的短名 (根据8.3 命名规则)
ShortPath Returns the short path of a specified file (the 8.3 naming convention)
返回一个指定文件的短路径 (根据8.3 命名规则)
Size Returns the size, in bytes, of a specified file
返回指定文件所包含的字节数
Type Returns the type of a specified file
返回指定文件的类型

Methods
方法

Method
方法
Description
描述
Copy Copies a specified file from one location to another
将本机上的文件复制到异地机子上
Delete Deletes a specified file
删除指定文件
Move Moves a specified file from one location to another
将本机上的文件移动到异地机子上
OpenAsTextStream  Opens a specified file and returns a TextStream object to access the file
打开指定文件返回一个TextStream对象

评论 (0) All

登陆 | 还没注册?