ASP File Object
- Previous Page ASP Drive
- Next Page ASP Folder
Το αντικείμενο File χρησιμοποιείται για να επιστρέψει πληροφορίες για το καθορισμένο αρχείο.
Παράδειγμα
- Πότε δημιουργήθηκε το αρχείο;
- Αυτό το παράδειγμα δείχνει πώς να δημιουργήσετε πρώτα το αντικείμενο FileSystemObject και στη συνέχεια να χρησιμοποιήσετε την ιδιότητα DateCreated του αντικειμένου File για να αποκτήσετε την ημερομηνία και την ώρα δημιουργίας του καθορισμένου αρχείου.
- Πότε το αρχείο αυτό έχει τροποποιηθεί;
- Αυτή η παράδειγμα δείχνει πώς να χρησιμοποιήσετε την ιδιότητα DateLastModified για να αποκτήσετε την ημερομηνία και την ώρα της τελευταίας τροποποίησης του καθορισμένου αρχείου.
- When was this file accessed?
- This example demonstrates how to use the DateLastAccessed property to obtain the date and time when the specified file was last accessed.
- Return the attributes of the specified file
- This example demonstrates how to use the Attributes to return the attributes of the specified file.
File object
The File object is used to return information about the specified file.
To operate on the properties and methods of the File object, we need to create an instance of the File object through the FileSystemObject. First, create a FileSystemObject object, and then use the GetFile method of the FileSystemObject object, or use the Files property of the Folder object to illustrate this File object.
The following code demonstrates how to use the GetFile method of the FileSystemObject object to illustrate this File object and use the DateCreated property to return the date when the specified file was created:
<% 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: 8/8/2008 10:01:19 AM
Properties and methods of the File object
Attributes
Attributes | Description |
---|---|
Attributes | Set or return the attributes of the specified file. |
DateCreated | Return the date and time when the specified file was created. |
DateLastAccessed | Return the date and time when the specified file was last accessed. |
DateLastModified | Return the date and time when the specified file was last modified. |
Drive | Return the drive letter of the drive where the specified file or folder is located. |
Name | Set or return the name of the specified file. |
ParentFolder | Return the parent folder object of the specified file or folder. |
Path | Return the path of the specified file. |
ShortName | Return the short name (8.3 naming convention) of the specified file. |
ShortPath | Return the short path (8.3 naming convention) of the specified file. |
Size | Return the size (in bytes) of the specified file. |
Type | Return the type of the specified file. |
Method
Method | Description |
---|---|
Copy | Copy a specified file from one location to another. |
Delete | Delete a specified file. |
Move | Move a specified file from one location to another. |
OpenAsTextStream | Open a specified file and return a TextStream object to access this file. |
- Previous Page ASP Drive
- Next Page ASP Folder