anusha

anusha

  • NA
  • 5
  • 0

Problem in reading special characters using c#

Apr 14 2009 2:54 AM

Hai,

   I am trying to read a text file and write the text in a html file using c#. But when I opened the html file in the browser the special characters got collapsed.

Here is the text file content:

 A slightly vainer factor to take into account is how you look to your contemporaries and other players on the course – if you look good, you’ll feel good and that will increase your confidence and performance on the day.

This is output I got in the browser:

A slightly vainer factor to take into account is how you look to your contemporaries and other players on the course � if you look good, you�ll feel good and that will increase your confidence and performance on the day.

Can anybody tell me how to handle this.

This is my c# code

FileInfo fi1 = new FileInfo("C:/Documents and Settings/anusha.ESPL/Desktop/mytext.txt");

if (fi1.Exists)

{

StreamReader sr = new StreamReader(fi1.FullName);

string content = sr.ReadToEnd();

sr.Close();

FileInfo fi2 = new FileInfo("C:/Documents and Settings/anusha.ESPL/Desktop/Untitled-1.htm");

if (fi2.Exists)

{

StreamWriter sw = new StreamWriter(fi2.FullName);

sw.Write(content);

sw.Close();

}

}

Thanks

Anusha.

  

 


Answers (2)