Solved

Create File of files in a folder

Posted on 1998-08-22
1
142 Views
Last Modified: 2010-04-30
How can I create a file that contains a listing of all of the files with a .dat extension?  Using vb on windows95.
0
Comment
Question by:Lee5
1 Comment
 

Accepted Solution

by:
fc_hnat earned 50 total points
ID: 1430428
Try this Lee5.
This
Private Sub Command1_Click()
   
    On Error GoTo ErrorHandler
     
    For x = 67 To 90
        Drive = Chr(x) & ":"
        ChDrive (Drive)
    Open "F:\MyFile" & Chr(x) & ".txt" For Output As #1
        MyFindFiles Drive & "\<path>", "*.*" ' replace path with folder.
    Close 1
10  Next
     
    MsgBox "Done."
     
    Exit Sub
     
ErrorHandler:
    Resume 10

End Sub
Private Sub MyFindFiles(ByVal sPath As String, ByVal sFilePattern As String)
    Dim sFile As String
    Dim coldir() As String
    Dim y As Integer
         
    On Error Resume Next
         
    sFile = Dir$(sPath & sFilePattern)
    While sFile <> ""
        If Left$(sFile, 1) <> "." Then
            Print #1, sPath & sFile
        End If
        sFile = Dir$
    Wend
             
    sFile = Dir$(sPath, 16)
    While sFile <> ""
        If Left$(sFile, 1) <> "." Then
            If GetAttr(sPath & sFile) And 16 Then
                y = y + 1
                ReDim Preserve coldir(y)
                coldir(y) = sPath & sFile & "\"
            End If
        End If
        sFile = Dir$
    Wend
         
    For z = 1 To y
        MyFindFiles coldir(z), sFilePattern
    Next
         
    Erase coldir
    y = 0

End Sub


0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error when passing an argument to a vb6 that contains  '/' 7 37
Pass through dll 2 83
excel 2016 program to loop through scripts 6 35
powershell script 9 26
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question