Reputation: 8721
I'm making a batch processing application that should convert files from directory A and place them into directory B preserving the same path after the relative root directory. To do that I need some way to convert the input file path into output file path.
Example:
before: C:\MyProject\Files\Input_\file1.cs
after: C:\MyProject\Files\Output\file1.cs
——————————————————— ————————
↑ ↓ these remain unchanged ↑ ↓
——————————————————— —————————————————————————
before: C:\MyProject\Files\Input_\folder\subfolder\file2.cs
after: C:\MyProject\Files\Output\folder\subfolder\file2.cs
I hope it's clear what I'm after. Is there a standard method in System.IO
namespace that can do this? If not, how do I implement it?
Upvotes: 0
Views: 8461
Reputation: 84
String.Replace("Input_","Output");
Get the path and assign to a string variable and do a replace.
Upvotes: 4
Reputation: 100527
Path class may help (at least in splitting file name from path and combining back), but you may need to do some string manipulations yourself too to replace particular component of the path.
Upvotes: 0