private void button1_Click(object sender, EventArgs e) { string directoryName = textBox1.Text.Trim(); //文件夹路径 string[] files = Directory.GetFiles(directoryName); foreach (string sDirectory in files) { string fileName = Path.GetFileName(sDirectory); //旧文件名 string newFileName = fileName.Split('_')[2]; //新文件名 string sNewDirectory = Path.Combine(directoryName, newFileName); //文件夹路径+新文件名 Directory.Move(sDirectory, sNewDirectory); } }