Solved

Read file in order

Posted on 2007-11-15
1
167 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
[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
 
LVL 27

Accepted Solution

by:
VBRocks earned 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

707 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