|
Option Explicit
'フォルダ内のファイルリストを作成
Private Sub ExGetFileList(strPath As String)
Dim i As Long
Dim tSfo As Object
Dim tGf As Object
Dim tFi As Object
Dim tSub As Object
Set tSfo = CreateObject("Scripting.FileSystemObject")
Set tGf = tSfo.GetFolder(strPath)
i = 10
For Each tFi In tGf.Files
'ファイル名
Cells(i, 2) = tFi.Name
'パス内に含まれるファイルの拡張子を除いたものを取得
Cells(i, 3) = tSfo.GetBaseName(tFi.Path)
'ファイルの拡張子
Cells(i, 4) = tSfo.GetExtensionName(tFi.Path)
'フォルダ名
Cells(i, 5) = tFi.ParentFolder.Path
'ファイルサイズ KByte
Cells(i, 6) = Int(tFi.Size / 1024)
'作成された日付・時刻
Cells(i, 8) = tFi.DateCreated
'ファイルの最終更新された日付・時刻
Cells(i, 10) = tFi.DateLastModified
'ファイルの最終アクセスの日付・時刻
Cells(i, 9) = tFi.DateLastAccessed
i = i + 1
Next
End Sub
Private Sub CommandButton1_Click()
ExGetFileList "c:\MyDir"
End Sub
|
|