我用UTF-8编码写文件时,老是有多个UTF-8头BOM,但是我想在使用的时候又不要显示它。
我自己读的时候我可以去掉,但是系统读的时候又不能操作了。
我想生成一个.MF文件就会因为有个BOM头而不能在手机上被识别。
有没有什么办法可以在写的时候不写这个进去呢?

解决方案 »

  1.   

    private static void Filewrier(string path, string str)
            {
                byte[] contents = new UTF8Encoding(false).GetBytes(str);
                using (FileStream outstream = File.Create(path, contents.Length))
                {
                    outstream.Write(contents, 0, contents.Length);
                    outstream.Close();
                }         }
    已经搞定。
      

  2.   

    private static void Filewrier(string path, string str)
            {
                byte[] contents = new UTF8Encoding(false).GetBytes(str);
                using (FileStream outstream = File.Create(path, contents.Length))
                {
                    outstream.Write(contents, 0, contents.Length);
                    outstream.Close();
                }         }
    已经搞定。