V
Viorel
About FileStream and StreamWriter!?
I have a string1 which contains(of course in unicode) a html code with
Unicode charset specified in it.
1)
byte[]content= System.Text.UnicodeEncoding.Unicode.GetBytes(string1);
System.IO.FileStream wr=new System.IO.FileStream("C:\\myhtml.html"
,System.IO.FileMode.CreateNew);
wr.Write(content,0,content.Length);
wr.Close();
When I opened the file some characters are unreadable, so something is wrong
in my code above, but then I have done:
2)
byte[]content= System.Text.UnicodeEncoding.Unicode.GetBytes(string1);
//System.IO.FileStream wr=new //System.IO.FileStream("C:\\myhtml.html"
,System.IO.FileMode.CreateNew);
//wr.Write(content,0,content.Length);
//wr.Close();
System.IO.StreamWriter tr=new System.IO.StreamWriter("C:\\myhtml.html"
,,false,System.Text.Encoding.Unicode);
string teststr=System.Text.Encoding.Unicode.GetString(content);
tr.Write(teststr);//(I did not simply used string1 in it because of reason
of testing)
And file was in good form, why first time wasn't good as second?
Tanks to all!
I have a string1 which contains(of course in unicode) a html code with
Unicode charset specified in it.
1)
byte[]content= System.Text.UnicodeEncoding.Unicode.GetBytes(string1);
System.IO.FileStream wr=new System.IO.FileStream("C:\\myhtml.html"
,System.IO.FileMode.CreateNew);
wr.Write(content,0,content.Length);
wr.Close();
When I opened the file some characters are unreadable, so something is wrong
in my code above, but then I have done:
2)
byte[]content= System.Text.UnicodeEncoding.Unicode.GetBytes(string1);
//System.IO.FileStream wr=new //System.IO.FileStream("C:\\myhtml.html"
,System.IO.FileMode.CreateNew);
//wr.Write(content,0,content.Length);
//wr.Close();
System.IO.StreamWriter tr=new System.IO.StreamWriter("C:\\myhtml.html"
,,false,System.Text.Encoding.Unicode);
string teststr=System.Text.Encoding.Unicode.GetString(content);
tr.Write(teststr);//(I did not simply used string1 in it because of reason
of testing)
And file was in good form, why first time wasn't good as second?
Tanks to all!