Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / December 2005

Tip: Looking for answers? Try searching our database.

UNIX formatted file content handling

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mesterak - 26 Dec 2005 08:12 GMT
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
Cor Ligthert [MVP] - 26 Dec 2005 09:36 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.