frmMain.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class frmMain : Form
{
string FolderPath;
public frmMain()
{
InitializeComponent();
}
// 下载于www.51aspx.com
private void button3_Click(object sender, EventArgs e)
{
FBD.ShowDialog();
FolderPath = FBD.SelectedPath;
this.textBox1.Text = FolderPath;
}
// 下载于www.51aspx.com
private void button1_Click(object sender, EventArgs e)
{
int i, j;
if (FolderPath.ToString().Trim()=="") {
MessageBox.Show("文件夹路径不能为空!","提示",MessageBoxButtons.OK);
return;
}
DirectoryInfo di = new DirectoryInfo(FolderPath);
renameFiles(FolderPath, textBox2.Text, textBox3.Text,this.PB);
MessageBox.Show("文件名修改完毕!", "", MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private static void renameFiles(string folderPath, string findString, string replaceWith,ProgressBar PB)
{
bool ret = false;
try
{
DirectoryInfo di = new DirectoryInfo(folderPath);
string destFileName = "";
PB.Minimum = 0;
PB.Maximum = di.GetFiles().Length;
foreach (FileInfo fi in di.GetFiles())
{
if (fi.Name.IndexOf(findString) > -1)
{
PB.Value = PB.Value + 1;
destFileName = fi.DirectoryName + "\\" + fi.Name.Replace(findString, replaceWith);
//MessageBox.Show(destFileName, "ti", MessageBoxButtons.OK);
File.Move(fi.FullName, destFileName);
}
}
ret = true;
PB.Value = 0;
}
catch (System.Exception ex)
{
throw new ApplicationException("Error in renameFiles", ex);
}
后面还有 32 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。