在 C# 表单中重命名文件夹
我尝试在 C# 中制作一个 Form 程序来重命名很多文件夹.客户必须选择文件夹(以及要重命名的名称),其中包含所有文件夹,例如在 c:\folders\ 中是此文件夹:
i try to make a Form program in c# to rename a lot of folders. The Customers has to choose the folder (and the name to rename), where all the folders are include, for example in c:\folders\ are this folders:
1991 - title1
1992 - title2
1993 - title3
1994 - title4
现在我要把年份改成一个名字,就像这样:
And now i will change the year into a name, like this:
name - title1
name - title2
name - title3
name - title4
示例图片:
我希望你能理解我想要的 :-) 并且你能帮我解决这个问题.
I hope you unterstand what i want :-) and you can help me with this.
问候,马蒂亚斯
一些提示:
获取所有文件(递归,如果你想要)与
Get all files (recursively if you want) with
Directory.GetFiles(@"c:\folder\")
Directory.GetFiles(@"c:\folder\")
重命名所有文件
File.Move(@"C:\folder\oldname",@"C:\文件夹\新名称");
File.Move(@"C:\folder\oldname", @"C:\folder\newname");
如果您的文件格式是这样,您可以简单地将文件名拆分为-" &用你的名字替换第一部分.
If your file format is like that you can simply split the filename at "-" & replace the first part with your name.