ASP: Scripting.FileSystemObject... how to read file or folder information

As promised I would like to explain other useful methods related to the Scripting.FileSystemObject. Infact you can obtain information on a file by simply calling different methods. As I wrote a few days ago in the "ASP: Scripting.FileSystemObject... how to move, copy and delete a file or a folder" post, just start by setting the object:
<%
Dim FSO
   Set FSO = Server.CreateObject("Scripting.FileSystemObject")
and the target file:
Dim varfile
Dim filepath
Dim fileinfo
   filepath = yourfilepath
   varfile = Server.MapPath(filepath)
The yourfilepath variable could be something like "/doc/abc.txt". With the Server.MapPath we determine the complete path.
Now we use the GetFile method:
Set fileinfo = FSO.GetFile(varfile)
And there you go; all the information are available through the fileinfo object.
With fileinfo
   Response.write ("Name: " & .Name & "
" & _
   "Short name: " & .ShortName & "
" & _
   "Size: " & .Size & "
" & _
   "Type: " & .Type & "
" & _
   "Attributes: " & .Attributes & "
" & _
   "Drive: " & .Drive & "
" & _
   "Path: " & .Path & "
" & _
   "Short path: " & .ShortPath & "
" & _
   "Folder: " & .ParentFolder & "
" & _
   "Creation date: " & .DateCreated & "
" & _
   "Last modification date: " & .DateLastModified & "
" & _
   "Last access date: " & .DateLastAccessed)
End With
For the extension of the file, you can use:
Response.write FSO.GetExtensionName(varfile)
Or check if the file exists:
Response.write FSO.GetExtensionName(varfile)
All the given examples can be used to retrieve information of a folder as well, just remember that instead of "file" we need to use "folder"; for example we use GetFolder instead of GetFile, FolderExists instead of FileExists and so on.
Set Folder = FSO.GetFolder("C:\doc\")
  With Folder
   Response.write ("Name: " & .Name & "
" & _
   "Short name: " & .ShortName & "
" & _
   "Creation date: " & .DateCreated & "
" & _
   "Attributes: " & .Attributes & "
" & _
   "Last access: " & .DateLastAccessed & "
" & _
   "Last modification date: " & .DateLastModified & "
" & _
   "Drive: " & .Drive & "
" & _
   "Is root folder: " & .IsRootFolder & "
" & _
   "Parent folder: " & .ParentFolder & "
" & _
   "Short path: " & .ShortPath & "
" & _
   "Size: " & .Size & "
" & _
   "Type: " & .Type)
End With
Other interesting methods are GetFileName, GetParentFolderName, GetBaseName and BuildPath. I think the methods are quite self explanatory, except the BuildPath that is used to obtain the complete path of a file, starting from the root folder:
Response.write FSO.BuildPath(folder, filename)
where folder could be "C:/doc" and filename "abc.txt".
In the end you could find useful the GetDrive method, which gets the information on a specific drive:
Set Drive = FSO.GetDrive("C:")
  With Drive
   Response.write ("Available space in bytes: " & .AvailableSpace & "
" & _
   "Free space in bytes: " & .FreeSpace & "
" & _
   "Drive letter: " & .DriveLetter & "
" & _
   "Drive type: " & .DriveType & "
" & _
   "File system (FAT, NTFS, CDFS): " & .FileSystem & "
" & _
   "Ready: " & .IsReady & "
" & _
   "Root folder: " & .RootFolder & "
" & _
   "Serial number: " & .SerialNumber & "
" & _
   "Share name: " & .ShareName & "
" & _
   "Total size: " & .TotalSize & "
" & _
   "Volume name: " & .VolumeName)
  End With
%>
As you can see, it's really quite simple to create a file management system. Sometimes in your web application you can apply some of this methods according to your needs. Sometimes could be dangerous because of security issues, but knowing that you can do it, and how to do it, might be very handy.
IMPORTANT: remember that when working with the Scripting.FileSystemObject, you should consider the related security issues. If you have problems in using the code above, remember that read and/or write permissions of the working folder must be given to the "IUSR" account. Use it with great care and attention!
Related posts:
ASP: Scripting.FileSystemObject... how to move, copy and delete a file or a folder
JQuery: 5 useful file upload plugins
VBScript: How to check if a file exists on a remote server