No real answer to this question

  • Thread starter Thread starter Technomage Awunes
  • Start date Start date
T

Technomage Awunes

It would seam the 2nd person to post on this website did not make it clear
as to what news group they were in.
http://www.eggheadcafe.com/forumarchives/NETFrameworkNETWindowsForms/Jun2005/post23269464.asp

The point is I would like to know the answer to the question posted on that
site.

Here is the question quoted:

hello members,

i m using windows form c#

using follwoing code

StreamWriter sw = new StreamWriter(new FileStream(@"c:\anyTextFile.txt",

FileMode.Append));

sw.WriteLine("this is test text \n now from here is next line");

sw.Flush();

sw.Close();

i m trying to write a simple text file, when i open that file in any text
pad

it shows data as follow

//**

this is test text

now from here is next line

**//

but when i open that file in windows notepad it shows data as follow

//**

this is test text ? now from here is next line

**//

that is theres sum square box inplace of linefeed,

i want if i open same file in notepad it shows same as of textpad, why it is

not showing, how to overcum that .

regards..
 
You are probably doing this:

writer.writeline( "first\nSecond" );

This writes:

First\nSecond\r\n

Solution 1 the obvious one:

writer.writeline( "first" );
writer.writeline( "Second" );

Solution 2:

String data = "first\nSecond";
String writeData = data.Replace( "\n", "\r\n" );
writer.writeline( writeData );
 
Thanks Ken,

I realized just after I posted this that I need to know a way to convert a
bunch of files that already have this output.

Any ideas on that?

Awunes
 
Technomage said:
Thanks Ken,

I realized just after I posted this that I need to know a way to convert a
bunch of files that already have this output.

Any ideas on that?

Read each file, replace "\n" with Environment.NewLine and write the text
back to the file.
 
It would seam the 2nd person to post on this website did not make it clear
as to what news group they were in.http://www.eggheadcafe.com/forumarchives/NETFrameworkNETWindowsForms/...

The point is I would like to know the answer to the question posted on that
site.

Here is the question quoted:

hello members,

i m using windows form c#

using follwoing code

StreamWriter sw = new StreamWriter(new FileStream(@"c:\anyTextFile.txt",

FileMode.Append));

sw.WriteLine("this is test text \n now from here is next line");

sw.Flush();

sw.Close();

i m trying to write a simple text file, when i open that file in any text
pad

it shows data as follow

//**

this is test text

now from here is next line

**//

but when i open that file in windows notepad it shows data as follow

//**

this is test text ? now from here is next line

**//

that is theres sum square box inplace of linefeed,

i want if i open same file in notepad it shows same as of textpad, why itis

not showing, how to overcum that .

regards..


You should use the Environment.NewLine instead of \n, \r, or their
combinations.

Eg.
...
string str1 = string.Format("Line1{0}Line2{0}Line3{0}",
Environment.NewLine);
...

Regards,
 
Back
Top