UNIX formatted file content handling

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have some log files I need to process via VB.NET and C# based applications.
I read the entire contents of each file individually into a string variable
using the StreamReader class (.ReadToEnd). I want to split the lines up from
each file and add the lines to an an ArrayList (via AddRange), but for some
reason I cannot come up with a way to split the lines correctly.

Can anyone please provide a method using string conversions or Regex to
alter the string content so I can split the string into lines correctly?

Thanks,

Matt
 
Mesterac,

You can split a file directly into an array with the different split
methods.
(There are more)

I hope this helps,

Cor
 
Correct...use split either via string method or Regex, but split by what?
UNIX formatted files do not end in equivalent of vbCrLf. I cannot determine
the correct character or sequence of characters which indicate end of line.
 
Correct...use split either via string method or Regex, but split by
what? UNIX formatted files do not end in equivalent of vbCrLf. I
cannot determine the correct character or sequence of characters
which indicate end of line.


DOS uses <CR><LF> Unix just uses <LF> - so you should be able to split
on <LF>.

Can you look at the file in a hex editor to confirm?
 
UNIX formatted file ends in hex 0A. Windows formatted file ends in
hex 0D followed by 0A.

That's correct <LF> and <CR><LF> as I said. So can you split on <LF>?
 
This is a test Junk Mail.
-----Original Message-----
From: Cor Ligthert [MVP] [mailto:[email protected]]
Posted At: Monday, December 26, 2005 3:06 PM
Posted To: microsoft.public.dotnet.general
Conversation: UNIX formatted file content handling
Subject: Re: UNIX formatted file content handling



Mesterac,

You can split a file directly into an array with the different split methods.
(There are more)

I hope this helps,

Cor
 
Back
Top