Файловый объект ASP
Объект File используется для возврата информации об указанном файле.
Дополнительные примеры
Как получить дату и время последнего изменения указанного файла.
Как получить дату и время последнего обращения к указанному файлу.
Как вернуть атрибуты указанного файла.
Файловый объект
Объект File используется для возврата информации об указанном файле.
Для работы со свойствами и методами объекта File вам потребуется создать экземпляр объекта File через объект FileSystemObject. Первый; создайте объект FileSystemObject, а затем создайте экземпляр объекта File с помощью метода GetFile объекта FileSystemObject или с помощью свойства Files объекта Folder.
В следующем коде используется метод GetFile объекта FileSystemObject для создания экземпляра объекта File и свойства 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
%>
Свойства и методы объекта File описаны ниже:
Характеристики
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) |
ShortPath | Returns the short path of a specified file (the 8.3 naming convention) |
Size | Returns the size, in bytes, of a specified file |
Type | Returns the type of a specified file |
Методы
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 |