"File" Class - File Folder

This section provides a tutorial example on how to use the File class that represents a file of a file system. File class is provided in the Scripting Runtime DLL, scrrun.dll.

File: A class representing a file in a file system. It offers the following properties and methods:

Here is a sample ASP page to show you how to get detailed information about a file.

<script language="vbscript" runat="server">
'  folder_test.asp
'  Copyright (c) 1999 by Dr. Herong Yang
'  This program shows how to browse the directory tree of a drive.
'
   response.write("<html><body>")
   response.write("<b>Tests on the File class</b>:<br/>")
   ' Creating a FileSystemObject object
   set fs = CreateObject("Scripting.FileSystemObject")
   set f = fs.GetFile("c:\winnt\system32\scrrun.dll")
   ' Display detailed information about this file
   response.write("Path = " & f.Path & "<br/>")
   response.write("Name = " & f.Name & "<br/>")
   response.write("Short Name = " & f.ShortName & "<br/>")
   response.write("Short Path = " & f.ShortPath & "<br/>")
   response.write("Drive = " & f.Drive & "<br/>")
   response.write("Size = " & f.Size & "<br/>")
   response.write("Attributes = " & f.Attributes & "<br/>")
   response.write("Date Created = " & f.DateCreated & "<br/>")
   response.write("</body></html>")
</script>

Output:

Tests on the File class:
Path = C:\WINNT\system32\scrrun.dll
Name = scrrun.dll
Short Name = scrrun.dll
Short Path = C:\winnt\system32\scrrun.dll
Drive = c:
Size = 147512
Attributes = 32
Date created = 6/26/2001 6:06:58 PM

Last update: 2002.

Table of Contents

 About This Book

 ASP (Active Server Pages) Introduction

 IIS (Internet Information Services) 5.0

 MS Script Debugger

 VBScript Language

 ASP Built-in Run-time Objects

 ASP Session

 Creating and Managing Cookies

 Managing Sessions with and without Cookies

scrrun.dll - Scripting Runtime DLL

 What Is scrrun.dll?

 "Dictionary" Class - Collection of Key-Value Pairs

 "FileSystemObject" Class - File System

 "Drive" Class - Disk Drive

 "Folder" Class - File Folder

"File" Class - File Folder

 "TextStream" Class - Input or Output Stream

 Managing Response Header Lines

 Calculation Speed and Response Time

 ADO (ActiveX Data Object) DLL

 Working with MS Access Database

 Guest Book Application Example

 References

 PDF Printing Version