自己写的代码生成器,生成__manifest__.py,发现始终无法安装,
查询后原来是生成的编码默认是UTF-8带签名的的,
改成不带签名的方法
/// <summary>
/// 写文件,编码是UTF-8 ,不带签名
/// </summary>
/// <param name="path"></param>
/// <param name="text"></param>
public static void Write(string path, string text)
{
string dirpath = Path.GetDirectoryName(path);
if (!Directory.Exists(dirpath))
{
Directory.CreateDirectory(dirpath);
}
//FileStream fs = new FileStream(path, FileMode.Create);
//StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("UTF-8"));
System.Text.UTF8Encoding utf8 = new System.Text.UTF8Encoding(false);
var sw = new StreamWriter(path, false, utf8);
sw.Write(text);
sw.Flush();
sw.Close();
//fs.Close();
}