diablo089
asked on
Getting subdirectory substrings
I'm trying to copy files from one directory to another directory. I'm having issues recreating nested subdirectories.
Currently, my code grabs the subdir.Name property of a directory, and this works fine for one level of subdirectory for each directory. (ie Directory/subdirectory).
How can I get a substring of the qualified nested subdirectories? If I have Dir1/Sub1/Sub2/Sub3, I want to grab the substring "/Sub1/Sub2/Sub3" from the full path of Dir1.
Currently, my code grabs the subdir.Name property of a directory, and this works fine for one level of subdirectory for each directory. (ie Directory/subdirectory).
How can I get a substring of the qualified nested subdirectories? If I have Dir1/Sub1/Sub2/Sub3, I want to grab the substring "/Sub1/Sub2/Sub3" from the full path of Dir1.
Can you post the code that deals with grabbing the path(s)?
And out of curiousity, are you not using:
This returns the full path names so you'd have to remove the parent folder names; however, I thought there was some stuff built in that did this for you.
Directory.GetDirectories(@"YourPathHere", "*", SearchOption.AllDirectories)
This returns the full path names so you'd have to remove the parent folder names; however, I thought there was some stuff built in that did this for you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Substring from dir1 by replacing dir1 with "" (empty string) works for my needs. Thanks guys!