I have this code:
string s = "آ";
StreamWriter writer = new StreamWriter("a.txt", false, Encoding.UTF8);
writer.WriteLine(s);
but when I run it I can’t see any “آ” in a.txt!! There isn’t any string in a.txt! It is Empty! What is problem!?! Can anyone help me???
You never
Close()theStreamWriter.If you call
writer.Close()when you finish writing, you will see the character.But, since it implements
IDisposableyou should wrap the creation of theStreamWriterin ausingstatement:This will close the stream for you.