Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Read file in order

Posted on 2007-11-15
1
Medium Priority
?
170 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 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

618 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