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
mesterak - 26 Dec 2005 10:12 GMT
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.
> Mesterac,
>
[quoted text clipped - 5 lines]
>
> Cor
Jeff Gaines - 26 Dec 2005 10:29 GMT
> 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?

Signature
Jeff Gaines
mesterak - 26 Dec 2005 10:44 GMT
UNIX formatted file ends in hex 0A. Windows formatted file ends in hex 0D
followed by 0A.
> > Correct...use split either via string method or Regex, but split by
> > what? UNIX formatted files do not end in equivalent of vbCrLf. I
[quoted text clipped - 5 lines]
>
> Can you look at the file in a hex editor to confirm?
Jeff Gaines - 26 Dec 2005 12:40 GMT
> > > Correct...use split either via string method or Regex, but split
> > > by what? UNIX formatted files do not end in equivalent of
[quoted text clipped - 5 lines]
> >
> > 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>?

Signature
Jeff Gaines
sanjay - 26 Dec 2005 13:28 GMT
This is a test Junk Mail.
-----Original Message-----
From: Cor Ligthert [MVP] [mailto:notmyfirstname@planet.nl]
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