Zcumbag
09-08-2006, 06:11 AM
Hi,
I have a project where I create text-files. My project is configured to use UTF-8 encoding wich is why (i'm guessing) the text-files I create uses UTF-8 encoding.
How can I upon creating textfiles make sure it uses ANSI-encoding?
My code:
public static void Append(string message, string file)
{
if (!File.Exists(SOFilePath + GenDateTime + file))
{
FileStream fs = File.Create(SOFilePath + GenDateTime + file);
fs.Close();
}
try
{
StreamWriter sw = File.AppendText(SOFilePath + GenDateTime + file);
sw.Write(message);
sw.Flush();
sw.Close();
}
catch (Exception exc)
{
throw;
}
}
I have a project where I create text-files. My project is configured to use UTF-8 encoding wich is why (i'm guessing) the text-files I create uses UTF-8 encoding.
How can I upon creating textfiles make sure it uses ANSI-encoding?
My code:
public static void Append(string message, string file)
{
if (!File.Exists(SOFilePath + GenDateTime + file))
{
FileStream fs = File.Create(SOFilePath + GenDateTime + file);
fs.Close();
}
try
{
StreamWriter sw = File.AppendText(SOFilePath + GenDateTime + file);
sw.Write(message);
sw.Flush();
sw.Close();
}
catch (Exception exc)
{
throw;
}
}