I have a task of changing the names of some files (that is, adding id to each name dynamically) in a folder using C#.
Example: help.txt to 1help.txt
How can I do this?
Have a look at FileInfo.
Do something like this:
void RenameThem() { DirectoryInfo d = new DirectoryInfo("c:/dir/"); FileInfo[] infos = d.GetFiles("*.myfiles"); foreach(FileInfo f in infos) { // Do the renaming here File.Move(f.FullName, Path.Combine(f.DirectoryName, "1" + f.Name)); } }
1.4m articles
1.4m replys
5 comments
57.0k users