473,473 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

UNIX formatted file content handling

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
Dec 26 '05 #1
6 1186
Mesterac,

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

I hope this helps,

Cor
Dec 26 '05 #2
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.

"Cor Ligthert [MVP]" wrote:
Mesterac,

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

I hope this helps,

Cor

Dec 26 '05 #3
On 26/12/2005 mesterak wrote:
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?

--
Jeff Gaines
Dec 26 '05 #4
UNIX formatted file ends in hex 0A. Windows formatted file ends in hex 0D
followed by 0A.

"Jeff Gaines" wrote:
On 26/12/2005 mesterak wrote:
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?

--
Jeff Gaines

Dec 26 '05 #5
On 26/12/2005 mesterak wrote:
"Jeff Gaines" wrote:
On 26/12/2005 mesterak wrote:
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>?

--
Jeff Gaines
Dec 26 '05 #6
This is a test Junk Mail.
-----Original Message-----
From: Cor Ligthert [MVP] [mailto:no************@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
Dec 26 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: dawn | last post by:
Hi all, I am now working on a C program under Unix. The requirement for the program is that: A file name is passed to program as a parameter. The program will Find files under a specified...
14
by: Al Smith | last post by:
I need help in implementing proper error handling. I am trying to upload a file based on the sample code below. The code works well except if the file selected is too big. I do know about the...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
9
by: Jay Kim | last post by:
Hi, We're implementing a Windows application using Visual Basic .NET. One of the key features we need to implement is that we should be able to get the accurate byte offset of user selected...
7
by: D & J G | last post by:
Is there a way to instruct Windows file-handling - 'Opens with:' - from within VB6? I want to ensure that files with the .rtf (rich text) extension always go to Word Pad, no matter which future...
3
by: J055 | last post by:
Hi How do I tell the user he has tried to upload a file which is too big... 1. when the httpRuntime.maxRequestLength has been exceeded and 2. when the uploaded file is under then...
1
by: robbiesmith79 | last post by:
Just so this is out there on the web, I battled the past 24 hours about this. Background info... I developed a ecommerce website in PHP 4 on a shared linux hosting plan from GoDaddy and had the...
4
by: CoRrRan | last post by:
I would like to know how I can check, prior to opening a textfile, for DOS/UNIX/MAC formatting of the file. Is there a way to do this, or is it impossible? Thx, CoRrRan
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.