[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Read file in order

Posted on 2007-11-15
1
Medium Priority
?
171 Views
Last Modified: 2010-04-23
There are, for example, three file name "A.txt" "B.txt" "C.txt". Is it possible to reach these files in order. A, then B then C at a time.




For each myfile as fileinfo in mydir.getfiles("*.txt")

   Readmyfile...etc



Next
0
Comment
Question by:VBdotnet2005
1 Comment
 
LVL 27

Accepted Solution

by:
VBRocks earned 2000 total points
ID: 20290965
Here's how you can do it:

   Private Sub SortFiles()

        Dim mydir As String = "C:\temp"

        Dim list As New List(Of System.IO.FileInfo)
        list.AddRange(New IO.DirectoryInfo(mydir).GetFiles("*.txt"))
        list.Sort(AddressOf Sort)

        For Each myfile As System.IO.FileInfo In list
            Debug.WriteLine(myfile.Name)

        Next

    End Sub

    Private Function Sort(ByVal x As IO.FileInfo, ByVal y As IO.FileInfo) As Integer

        Return x.Name.CompareTo(y.Name)

    End Function

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

831 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