private static void WriteSitpulationFileEncoding(EncodingScrutatorFile file, Encoding encoding)
        {
            if (file.Encoding.Equals(Encoding.ASCII))
            {
                if (Equals(encoding, Encoding.UTF8) ||
                    Equals(encoding, Encoding.GetEncoding("GBK")) ||
                    Equals(encoding, Encoding.ASCII)) //对 ASCII不写入
                {
                    return;
                }
            }
            string str;

            using (var stream = new StreamReader(file.File.OpenRead(), file.Encoding))
            {
                str = stream.ReadToEnd();
            }
            using (var stream = new StreamWriter(new FileStream(file.File.FullName, FileMode.Create), encoding))
            {
                stream.Write(str);
            }
        }
示例#2
0
        ///// <summary>
        ///// 需要处理总数
        ///// </summary>
        //public double Amount { set; get; }
        ///// <summary>
        ///// 当前数
        ///// </summary>
        //public double ProgressCount { set; get; }

        public void ReportWriteSitpulationFile(EncodingScrutatorFile encodingScrutatorFile)
        {
            WriteSitpulationFileChanged?.Invoke(this, encodingScrutatorFile);
        }