Objeto de archivo ASP
El objeto File se utiliza para devolver información sobre un archivo especificado.
Más ejemplos
Cómo obtener la fecha y la hora en que se modificó por última vez un archivo específico.
Cómo obtener la fecha y la hora en que se accedió por última vez a un archivo específico.
Cómo devolver los atributos de un archivo especificado.
El objeto de archivo
El objeto File se utiliza para devolver información sobre un archivo especificado.
Para trabajar con las propiedades y métodos del objeto File, deberá crear una instancia del objeto File a través del objeto FileSystemObject. Primero; cree un objeto FileSystemObject y luego cree una instancia del objeto File mediante el método GetFile del objeto FileSystemObject o mediante la propiedad Files del objeto Folder.
El siguiente código usa el método GetFile del objeto FileSystemObject para instanciar el objeto File y la propiedad DateCreated para devolver la fecha en que se creó el archivo especificado:
Ejemplo
<%
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
%>
Las propiedades y métodos del objeto File se describen a continuación:
Propiedades
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 |
Métodos
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 |