How to write data to text file using ANSI format

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

I need to write this file in a web browser. Do they support ANSI?

0


source to share


2 answers


I'm not into ASP, so I can't tell you exactly how to do this. But I believe most (all?) Browsers support ANSI plain text. You can return the HTTP content type as text / plain and send the text as the content of your HTTP response.



+1


source


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



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

      

+3


source







All Articles