This question had asked for PowerShell before. I want to do this in C#.
I have a directory on my desktop. The directories name is “rename”.
C:\Users\dell\Desktop\rename
And “rename” folder contains “a_b”, “b_c”, “c_d”, “d_e” folders.
I want to replace “_” with “-” characters.
In other words, folders’ new names will be “a-b”, “b-c”, “c-d”, “d-e”
Thank you for your help!
Create a
DirectoryInfoobject representing therenamefolder, iterate through its subfolders, and useString.Replaceto replace_with-: