2
Answers

Problem in reading special characters using c#

anusha

anusha

15y
10.2k
1

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)