Fill a text document with a directories filenames and dates

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
 
J

JSand42737

"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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top