473,807 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ 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 1200
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.n l]
Posted At: Monday, December 26, 2005 3:06 PM
Posted To: microsoft.publi c.dotnet.genera l
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
2544
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 directory. The matched file must have the same content with the given file. It does not matter whether the filenames are the same. It is easy to find file that has the same name with given file, but may be hard to find the files that with the same...
14
3901
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 maxRequestLength parameter of the <httpRuntime> section and that works as expected. What I want is to enforce a max file size but haven't been able to trap the error thrown when the file is too large and that's where I could use some help.
1
5405
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 completely/succsessfully on the client's computer before updating some metadata on the server (file downloaded date for instance) However, All examples i have tried, and all examples I have found that other people says works - doesn't work for me :-(
15
4784
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 button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
9
2963
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 text in the file. We've been trying to use the RichTextBox control to load
7
7292
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 computer uses my program. TIA Don
3
4937
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 httpRuntime.maxRequestLength For point 1. it would be good to at least display a nice error page. IE seems to just display a blank page.
1
2949
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 html formatted emails sending as text/html and were going fine with limited header information. Then we moved the site over to a Dedicated Linux hosting plan. This time, it's PHP 5. Things are bound to not work as expected moving to a new...
4
2061
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
9720
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10626
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10372
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10112
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6879
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.