Solved

Create File of files in a folder

Posted on 1998-08-22
1
146 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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