After more than 14 years developing on different systems and using
.Net since 1.0, I thought this would be a trivial problem.

Today I was asked to parse and modify a 700+ MB file, it had to be
done today.  I got it done.  However, after slapping
together a program the original file and the finished file were not
the same size.  They should be.

After looking at the original file and the modified flat file, they
were off, the size diff was exactly 1 char per record/line
just about 1 million and 1 million bytes.  Hmm.  Same diff in file
size as number of records?  OK.  Easy.  The original
file was in a *nix LF-only format.  The processed file from .Net came
out in an MS CRLF.  Ah.  OK.

There are plenty of tools to convert.  I used Linux and dos2unix.

However, I started to Google for a way to write the file with LF-only
so it is in *nix format from the get-go.  Strangely,
Google showed just a bunch of freeware-type executable apps to do it.
I know that already.  I was and am looking
for a straight way to write out a plain text file (US, no Unicode
needed) from C# from the get-go.

Looking at the Encoding class I saw ASCII and other UTF-based typed.
I just want to write a plain ASCII file from C#
with *nix line endings of LF only.

Has anyone done this?  I know I can open and reprocess the file to fix
the line endings.  However, I don't want to have
to do that since the file is usually 700+MB.  I want to read through
it once, do the changes and write it out with and LF
EOL so it can be compressed and sent to another company for processing.

Any tips?

Thanks.

Reply via email to