UNIX formatted file content handling

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
 
C

Cor Ligthert [MVP]

Mesterac,

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

I hope this helps,

Cor
 
G

Guest

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.
 
J

Jeff Gaines

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?
 
G

Guest

UNIX formatted file ends in hex 0A. Windows formatted file ends in hex 0D
followed by 0A.
 
J

Jeff Gaines

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>?
 
S

sanjay

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top