Groups | Blog | Home
all groups > dotnet framework > june 2006 >

dotnet framework : Converting File Formats (Unix to Windows)


bcaller NO[at]SPAM gmail.com
6/7/2006 2:50:42 PM
Yep, just open the file and replace each \n with \r\n
______________
Compilr the online C, C#, VB.NET, Fortran compiler
http://www.caller.me.uk/Compilr
VC
6/7/2006 5:35:42 PM
Hi,
Greetings. Not sure if this is the right forum..... In case I should visit
some other forum please let me know.

Does Dot.NET provide a quick method/way to convert a UNIX text file to DOS
format?

Cheers!!!
V

Kevin Spencer
6/7/2006 5:40:17 PM
The short and sweet of it is, Unix text files use "\n" (LineFeed) for CRLFs.
Windows uses "\r\n" (CarriageReturn-LineFeed). Simplest explanation is,
replace "\n" with "\r\n".

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.

[quoted text, click to view]

VC
6/7/2006 6:49:56 PM
Thanks for your time Caller and Kevin. Appreciate it much.
I guess I have to do it the "Simple" way.... and replace "\n" with "\r\n"...

Cheers!!!
V!
[quoted text, click to view]

GhostInAK
6/8/2006 1:04:02 AM
Hello Kevin,

I'm commenting here without testing... but:
I do believe the StreamReader.ReadLine() function will read a single line
from a unix-encoded text file. So open the unix filestream in Read mode..
open an output filestream in Write mode.. and then in a loop do something
like:
Writer.WriteLine(Reader.ReadLine())

-Boo

[quoted text, click to view]

Kevin Spencer
6/8/2006 6:46:45 AM
Yes, you are correct. The ReadLine() function detects the type of line feed
used by the file, and reads the line excluding the line feed. This is also
an excellent way to accomplish the task.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.

[quoted text, click to view]

AddThis Social Bookmark Button