文件夹内修改文件名称
using System; using System.IO; namespace UsefulFunctions.Functions { public class ReviseFileNames { public void ReviseFileName(string addr1,string addr2) { var path = Directory.GetFiles(addr1); foreach (var str in path) { var file = new FileInfo(str); var f = file.Name.Substring(0, file.Name.LastIndexOf(".dwg", StringComparison.Ordinal)); if (!Directory.Exists(addr2)) { Directory.CreateDirectory(addr2); } var p = addr2 + f + "S.dwg" + file.Extension; file.MoveTo(p); } } } }