-
Try something like:
Code:
Private iFile As Integer
Private Sub Command1_Click()
iFile = FreeFile
Open "C:\Log.txt" For Output As iFile
Call LogFiles("*.*", "C:\")
Close iFile
Call Shell("notepad.exe C:\Log.txt", vbNormalFocus)
End Sub
Private Sub LogFiles(ByVal sFile As String, ByVal sStartDir As String)
Dim sSubDirs() As String
Dim iSubDirs As Integer
Dim sDir As String
If Right$(sStartDir, 1) <> "\" Then sStartDir = sStartDir & "\"
sDir = Dir(sStartDir & sFile, vbArchive + vbDirectory + vbHidden + vbNormal + vbReadOnly + vbSystem)
While Len(sDir)
If Left$(sDir, 1) <> "." Then
If (GetAttr(sStartDir & sDir) And vbDirectory) = vbDirectory Then
ReDim Preserve sSubDirs(iSubDirs)
sSubDirs(iSubDirs) = sDir
iSubDirs = iSubDirs + 1
Else
Print #iFile, sStartDir & sDir
End If
End If
sDir = Dir
Wend
If iSubDirs Then
For iSubDirs = 0 To iSubDirs - 1
Call LogFiles(sFile, sStartDir & sSubDirs(iSubDirs))
Next
End If
End Sub
N.B. If you do the Entire HDD it may take a while.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
I am working on a backup program to copy all files on a hard drive to the network. Here is the way it works now:
1) Generating a list of all the files on the hard drive using a batch file that pipes a DIR command to a text file.
2) Compare that file to another file that has a list of the files that do not need to be copied ( fresh install )
3) The user would go through the list, add and remove any neccesery on unneccesery files.
4) The program would generate a batch file to copy all the local files that the user selected to a network drive, creating folders as neccessery.
I'm trying to eliminate the use of the batch files. I can do the copying part in VB, but I'm not sure how to get a list of local files. All what the first batch file does is a
DIR C:\*.* /S/B/A-D > C:\LCLFIL.TXT
The output of this file looks something like this:
c:\SMS.NEW
c:\SMSSETUP.LOG
c:\WFCNAME.INI
c:\Acrobat3\Reader\ACROBAT.PDF
c:\Acrobat3\Reader\ACROFX32.DLL
So I need a way to do the same thing in VB and output it in the same format.
Any help would be appreciated.
Thanks
------------------
Joe Handal
Workstation Engineer
[email protected]
[This message has been edited by JoeH (edited 01-14-2000).]