By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

Parsing text in .NET

P: 2
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
Share this Question
Share on Google+
1 Reply


P: 2
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.