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?
See Question&Answers more detail:osI 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?
See Question&Answers more detail:osHave 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));
}
}