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

x
?
Solved

Open ASCII text file, read into ArrayList

Posted on 2006-11-02
3
Medium Priority
?
1,471 Views
Last Modified: 2012-06-27
I need code that will open an ASCII text file and read each line into an ArrayList, please.
0
Comment
Question by:Tom Knowlton
[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
3 Comments
 
LVL 10

Accepted Solution

by:
Kinger247 earned 1200 total points
ID: 17860445
knowlton try:

        Dim sr As New System.IO.StreamReader("C:\text.txt")
        Dim Line As String = sr.ReadLine()
        Dim arr As New ArrayList

        Do While Line IsNot Nothing
            arr.Add(Line)
            Line = sr.ReadLine()
        Loop
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 800 total points
ID: 17860544
Using a regular String Array:

        Dim sr As New System.IO.StreamReader("c:\someFile.txt")
        Dim lines() As String = Split(sr.ReadToEnd, vbCrLf)
        sr.Close()

A variation in loading an ArrayList:

        Dim sr As New System.IO.StreamReader("c:\someFile.txt")
        Dim lines As New ArrayList(Split(sr.ReadToEnd, vbCrLf))
        sr.Close()

With VB.Net 2005 you can make it a one-liner:

        Dim lines As New ArrayList(Split(My.Computer.FileSystem.ReadAllText("c:\someFile.txt"), vbCrLf))
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 17862854
Thank you so much.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

636 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