Click to See Complete Forum and Search --> : Creating ANSI text files


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;
}
}

sirpelidor
09-11-2006, 03:58 PM
check out this link (http://www.ondotnet.com/pub/a/dotnet/2002/08/05/io.html?page=5)

pay attention to "System.Text.UTF8Encoding" and the StreamWriter class, hope that helps

Zcumbag
09-14-2006, 04:19 AM
All right! That did point me in the right direction. Problem solved!

However...

I have another issue regarding streaming textfiles. is there a way to stream several textfiles to a user? lets say a user clicks a button (ASP.NET) and after my app does it's thing a few diffrent textfiles displays to the user.

My cuurent solution is that the app saves textfiles to a folder on the client-harddrive. Wich I would like to avoid.

Thanks!

sirpelidor
09-15-2006, 01:19 PM
I have another issue regarding streaming textfiles



sorry, I'm not sure if I understand your question, would you please explain more in detail?

Also if you don't mind, may I suggest you open a new question with a new thread? It'll be easier for reading to read and search (i.e. google).