Write text file in ASP.Net - C# without Byte Order Mark

Posted on 2010-01-11
Medium Priority
Last Modified: 2012-05-08
I'm using a StreamWriter in ASP.Net / C# to save a text file.  However; I need to be able to write a file without having the Byte Order Mark (BOM) written at the beginning of the file.  This requirement is needed because of a legacy program that reads in the text file and misinterprets the BOM.

The following code appends the three characters EF BB BF at the beginning of the file.

StreamWriter sw = new StreamWriter(this.FullFileName, false, System.Text.Encoding.UTF8);

I've tried many different variations of the System.Text.Encoding classes to save the text file with different encoding types/code pages; but I have not found a way to disable saving the BOM.  The strange thing is that at one point this exact code worked as needed (without the BOM), but I cannot figure out what in the system changed to cause my output to be altered.

In a nutshell ...
I need to write a standard 8-bit text file WITH OUT having Byte Order Mark characters at the beginning of the file.

Thank you in advance for your advice.
Question by:mdtanner
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 10

Accepted Solution

krunal_shah earned 2000 total points
ID: 26290202
Please check the following link, it may help you


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question