Article ID: 190029
Article Last Modified on 11/18/2003
Windows Script Host
Windows NT Option Pack
Microsoft Internet Information Server 3.0
Scripting 3.1 upgrade
Visual Studio 98
Visual Basic 6.0
Option Explicit
Private Sub Form_Load()
Label1.AutoSize = True
Label1.Caption = Dir1.Path
Dir1.Path = Drive1.Drive
Command1.Caption = "Create File List"
End Sub
Private Sub Dir1_Change()
Label1.Caption = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Command1_Click()
Dim fso As FileSystemObject
Dim f As Folder
Dim fc As Files
Dim fl As File
Dim ts As TextStream
Dim sFileName As String
Dim sVersion As String
Set fso = CreateObject("Scripting.FileSystemObject")
sFileName = InputBox("Enter File Name", _
"Enter Path and File Name")
If sFileName = "" Then
Exit Sub
Else
Set ts = fso.CreateTextFile(sFileName, True, False)
Set f = fso.GetFolder(Dir1.Path)
Set fc = f.Files
With ts
.WriteLine ("Files in " & Dir1.Path)
.WriteBlankLines (1)
For Each fl In fc
.WriteLine ("Filename: " & fl.Name)
.WriteLine (vbTab & "File Type: " & fl.Type)
' Get Version Information
sVersion = fso.GetFileVersion(fl.Path)
If sVersion <> "" Then
.WriteLine (vbTab & "Version: " & fso.GetFileVersion(fl.Path))
Else
.WriteLine (vbTab & "No Version Information")
End If
.WriteLine (vbTab & "Created: " & fl.DateCreated)
.WriteLine (vbTab & "Last Modified: " & _
fl.DateLastModified)
.WriteLine (vbTab & "Last Accessed: " & _
fl.DateLastAccessed)
.WriteLine (vbTab & "Path: " & fl.Path)
.WriteLine (vbTab & "Short Name: " & fl.ShortName)
.WriteLine (vbTab & "Size: " & fl.Size & " bytes")
.WriteBlankLines (1)
Next
End With
MsgBox (sFileName & " created.")
End If
'Destroy All Objects
Set fc = Nothing
Set f = Nothing
Set ts = Nothing
Set fso = Nothing
End Sub
Keywords: kbinfo kbfileio KB190029