ASPファイルオブジェクト
Fileオブジェクトは、指定されたファイルに関する情報を返すために使用されます。
その他の例
指定したファイルが最後に変更された日時を取得する方法。
指定されたファイルが最後にアクセスされた日時を取得する方法。
の属性を返す方法。
ファイルオブジェクト
Fileオブジェクトは、指定されたファイルに関する情報を返すために使用されます。
Fileオブジェクトのプロパティとメソッドを操作するには、FileSystemObjectオブジェクトを介してFileオブジェクトのインスタンスを作成する必要があります。初め; FileSystemObjectオブジェクトを作成してから、FileSystemObjectオブジェクトのGetFileメソッドまたはFolderオブジェクトのFilesプロパティを使用してFileオブジェクトをインスタンス化します。
次のコードは、FileSystemObjectオブジェクトのGetFileメソッドを使用して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 |