Ejemplo n.º 1
0
 /// <summary>
 /// 重编码载入的所有文件
 /// </summary>
 private void button_Click(object sender, EventArgs e)
 {
     if (checkBox.Checked)
     {
         RenameTool.ReName(files);
     }
     RecodeTool.ReCode(files, encode);
     MessageBox.Show("重编码完成");
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 文件重编码。根据文件的编码格式读取文件内容,输出为指定的编码格式,可指定仅修改指定后缀的文件
        /// </summary>
        public static void ReCode(String filePath, Encoding encoding = null, String[] Endwith = null)
        {
            if (File.Exists(filePath))
            {
                try
                {
                    if (!RenameTool.isEndWith(filePath, Endwith))
                    {
                        return;
                    }

                    String data = FileTool.fileToString(filePath);
                    FileTool.SaveProcess(data, filePath, encoding, true);
                }
                catch (Exception ex) { }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 文件重编码示例入口
        /// </summary>
        public static void Main(String[] args)
        {
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new ReCode_Form());
            }
            else
            {
                String[] files = DragDropTool.GetSubFiles(args);            // 载入文件信息

                String[] Endwith = new String[] { ".java", ".cs", ".txt", ".xml" };
                RenameTool.ReName(files, Endwith);                           // 重命名
                RecodeTool.ReCode(files, Encoding.UTF8, Endwith);            // 重编码所有文件
            }
        }