468,301 Members | 1,529 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

Parsing text in .NET

I have a simple VB application that I'm trying to build. The user selects a text file from a dialog box and then I need to parse the data in the file.

The layout of the file looks like this:

C:\ xxxxxx ; yyyyyy ; zzzz C:\ xxxxxx ; yyyyyy ; zzzz C:\ xxxxxx ; yyyyyy ; zzzz C:\ xxxxxx ;
yyyyyy ; zzzz C:\ xxxxxx ; yyyyyy ; zzzz C:\ xxxxxx ; yyyyyy ; zzzz C:\ xxxxxx ; yyyyyy ; zzzz

I need to generate a output so it looks like this:

C:\ xxxxxx ; yyyyyy ; zzzz
C:\ xxxxxx ; yyyyyy ; zzzz
C:\ xxxxxx ; yyyyyy ; zzzz
C:\ xxxxxx ; yyyyyy ; zzzz
C:\ xxxxxx ; yyyyyy ; zzzz

What would do the trick for this task? I've got a StreamReader object using:
Dim oFile As StreamReader = New StreamReader(OpenFileDialog.FileName.ToString)

Now I just need to parse through the text, find out where the "C:\" are write a line to a new text file until I hit another C:\ in the file.

I'm verrrrry new to VB .NET, last version of VB I used was VB5; yikes!

Thanks in advance
Nov 8 '06 #1
1 1363
Here is where I'm at so far. I can open the file, read it and re-write it with no problem to the output file. I need to figure out how to split up the string every time it encounters a "C:\".

Expand|Select|Wrap|Line Numbers
  1. Dim oFile As StreamReader = New StreamReade (OpenFileDialog.FileName.ToString)
  2.         Dim output As StreamWriter = New StreamWriter("Output.txt")
  3.         parseProgressBar.Visible = True
  4.         Dim line As String
  5.         line = oFile.ReadToEnd()
  6.         line.Split("C:\")  // This is what I need to get working.
  7.         output.WriteLine(line.ToString)
  8.         oFile.Close()
  9.         output.Close()
  10.  
Nov 8 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Terry | last post: by
4 posts views Thread by ralphNOSPAM | last post: by
3 posts views Thread by Pir8 | last post: by
7 posts views Thread by Lucas Tam | last post: by
4 posts views Thread by Earl | last post: by
2 posts views Thread by JaythePCguy | last post: by
9 posts views Thread by ankitdesai | last post: by
13 posts views Thread by Chris Carlen | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.