Solved

Read file in order

Posted on 2007-11-15
1
162 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 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now