//..................................................................... /// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonRuleMaking_Click(object sender, EventArgs e) { string message = "请使用 notepad++ 将你的文本文件 Encoding 保存成 ANSI 格式。\n\n" + "否则,中文的替换可能无法实现。"; MessageBox.Show(message, "注意事项", MessageBoxButtons.OK, MessageBoxIcon.Information); if (this.DialogFile.ShowDialog( ) != DialogResult.OK) { return; } string filename = this.DialogFile.FileName; string[] datalines = File.ReadAllLines(filename, Encoding.Default); FileInfo fileinfo = new FileInfo(filename); string pathname = fileinfo.DirectoryName; DirectoryInfo rootpath = fileinfo.Directory; StringBuilder buffer = new StringBuilder( ); foreach (FileInfo file in rootpath.GetFiles( )) { NamingRule batch = new NamingRule(file, datalines); buffer.AppendLine(batch.ToTxt(60)); } string result = pathname + "\\file-new-name-listing.txt"; File.WriteAllText(result, buffer.ToString( ), Encoding.Default); Process.Start("explorer.exe", pathname); return; }