www.webdeveloper.com
Results 1 to 4 of 4

Thread: Creating ANSI text files

  1. #1
    Join Date
    Nov 2003
    Location
    Kalmar, Sweden
    Posts
    35

    Creating ANSI text files

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

  2. #2
    Join Date
    Apr 2005
    Posts
    634
    check out this link

    pay attention to "System.Text.UTF8Encoding" and the StreamWriter class, hope that helps
    "Java is great, PHP sucks and .NET can't scale" - Shaun Connoly, JBoss's vice president of product development. April 5, 2006

  3. #3
    Join Date
    Nov 2003
    Location
    Kalmar, Sweden
    Posts
    35
    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!

  4. #4
    Join Date
    Apr 2005
    Posts
    634
    Quote Originally Posted by Zcumbag
    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).
    "Java is great, PHP sucks and .NET can't scale" - Shaun Connoly, JBoss's vice president of product development. April 5, 2006

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles