![]() |
WebCheatSheet.com |
![]() |
ASP File Object |
The File object represents a specified file on the local machine or on a network share. To work with the File object's properties and methods, you need to create an instance of the FileSystemObject object first and then instantiate the File object through the GetFile method. Also you can get a File object reference from the Folder object, by using the Files Collection. The File object properties and methods are as follows: Properties
Methods
How to use the ASP File Object In the following example we create an instance of the FileSystemObject object and then use the GetFile method to instantiate the File object. After that we use The File object properties to get the information about the specified file: <% Dim objFSO, objDrive 'Create a FileSystemObject instance Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 'Using the GetFile method of FileSystemObject object, initialize a File object Set objFile = objFSO.GetFile("c:\test.txt") 'Retrieve information about the file Response.Write "Name: " & objFile.Name & "<br />" Response.Write "ShortName: " & objFile.ShortName & "<br />" Response.Write "Size: " & objFile.Size & " bytes <br />" Response.Write "Type: " & objFile.Type & "<br />" Response.Write "Path: " & objFile.Path & "<br />" Response.Write "ShortPath: " & objFile.ShortPath & "<br />" Response.Write "Created: " & objFile.DateCreated & "<br />" Response.Write "LastModified: " & objFile.DateLastModified & "<br /><br />" %> |
![]() |
![]() |
Copyright © 2005-2007 www.WebCheatSheet.com All Rights Reserved. |