Fill a text document with a directories filenames and dates

  • Thread starter Thread starter Norma
  • Start date Start date
N

Norma

I am familiar with visual basic and I am trying to fill a
text document (could be a notepad doc) with a list of
filenames and the date/time field from a specific
directory. I would like to do this as a comma delimited
text file - these filename represent an account number and
the date is the last updated version. Any ideas you can
give me will be appreciated or if there are any
articles in the knowledge base that address this, I would
appreciate the Article and ID number.

Thansk
 
"Norma" <[email protected]> said:
I am familiar with visual basic and I am trying to fill a
text document (could be a notepad doc) with a list of
filenames and the date/time field from a specific
directory. I would like to do this as a comma delimited
text file - these filename represent an account number and
the date is the last updated version. Any ideas you can
give me will be appreciated or if there are any
articles in the knowledge base that address this, I would
appreciate the Article and ID number.

Thansk

Norma

Below is a small piece of code that loops through files in a given directory,
and puts the filename and the file date into a specified folder:


Public Sub sGetFiles(strFolder As String, strOutputFile As String)
On Error GoTo E_Handle
Dim strFile As String
Dim intOutputFile As Integer
intOutputFile = FreeFile
Open strOutputFile For Output As intOutputFile
If Right(strFolder, 1) = "\" Then strFolder = strFolder & "\"
strFile = Dir(strFolder, vbNormal)
Do Until strFile = ""
Print #intOutputFile, strFolder & strFile & "," &
FileDateTime(strFolder & strFile)
strFile = Dir
Loop
sExit:
On Error Resume Next
Reset
Exit Sub
E_Handle:
MsgBox Err.Description & vbCrLf & "sGetFiles", vbOKOnly + vbCritical,
"Error: " & Err.Number
Resume sExit
End Sub
 
Back
Top