tags:

views:

661

answers:

2

Using ASP.net, how do you write ANSI characters to a text file?

I need to write this file's text to the web browser. Do they support ANSI?

+2  A: 

Use System.IO.StreamWriter.
It has an constructor that accepts the encoding:

FileStream fs = new FileStream(fileName,
            FileMode.CreateNew, FileAccess.Write, FileShare.None);
StreamWriter writer = 
            new StreamWriter(fs, System.Text.Encoding.ASCII);
Aleris
+1  A: 

I don't do ASP, so I can't tell you how to do it exactly. But I believe most (all?) browsers do support ANSI plain text. You might return HTTP Content Type as text/plain, and send the text as the contents of your HTTP response.

Hosam Aly