C
C#2y ago
Cametolose

❔ Replace many files automatically

Hey, I want to replace hundreds or thousands of files with the same name. The files are saved in different directories. I already got it kinda working, but it don't replace files that are in different directories with the same name. Here is what I already have:
string SourcePath = "Path1";
string DestinationPath = "Path2";
foreach (string path in Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories))
File.Copy(path, path.Replace(SourcePath, DestinationPath), true);
string SourcePath = "Path1";
string DestinationPath = "Path2";
foreach (string path in Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories))
File.Copy(path, path.Replace(SourcePath, DestinationPath), true);
1 Reply
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server