(Type your message here)
Hi,
I want to open a file to read from and then edit and write the text to another file.
I am using StreamReader and StreamWriter for this purpose.
The problem is that i don't know the encoding of the file, because it can be saved at any encoding.
When using the stream objects it is using the UTF-8 encoding, and therefore after editting the file, some characters are omitted.
How can i know the file encoding? or any other solution?
The code i am using:
//Reading from file
StreamReader sReader = new StreamReader(path);
string str = sReader.ReadToEnd();
[..... edditing the string .....]
//writing to file
StreamWriter sStr = new StreamWriter(newpath);
sStr.Write(str);
Regards,
Gaia.
--------------------------------
From: Gaia C
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>PpWef8nJyUKZ0jfeAZs2LQ==</Id>