ASP File Object
- Vorige Pagina ASP Drive
- Volgende Pagina ASP Folder
Het File-object wordt gebruikt om informatie over een specifiek bestand terug te geven.
Voorbeeld
- Wanneer is dit bestand gemaakt?
- Dit voorbeeld demonstreert hoe je eerst een FileSystemObject-object moet maken, en vervolgens de DateCreated-eigenschap van het bestandobject gebruikt om de datum en tijd te verkrijgen wanneer een specifiek bestand is gemaakt.
- Wanneer is dit bestand gewijzigd?
- Dit voorbeeld demonstreert hoe je de DateLastModified-eigenschap kunt gebruiken om de datum en tijd te verkrijgen wanneer een specifiek bestand is gewijzigd.
- 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 properties of the specified file
- This example demonstrates how to use Attributes to return the properties 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 illustrate this File object through the GetFile method of the FileSystemObject object, or through the Files property of the Folder 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
Properties
Properties | Beschrijving |
---|---|
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 of the specified file (8.3 naming convention). |
ShortPath | Return the short path of the specified file (8.3 naming convention). |
Size | Return the size of the specified file (in bytes). |
Type | Return the type of the specified file. |
Methode
Methode | Beschrijving |
---|---|
Copy | Kopieer een specifiek bestand van de ene locatie naar de andere locatie. |
Delete | Verwijder een specifiek bestand. |
Move | Verplaats een specifiek bestand van de ene locatie naar de andere locatie. |
OpenAsTextStream | Open een specifiek bestand en retourneer een TextStream object om toegang te krijgen tot dit bestand. |
- Vorige Pagina ASP Drive
- Volgende Pagina ASP Folder