Solved

Create File of files in a folder

Posted on 1998-08-22
1
147 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

734 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