Link to home
Start Free TrialLog in
Avatar of diablo089
diablo089Flag for United States of America

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.
Avatar of kaufmed
kaufmed
Flag of United States of America image

Can you post the code that deals with grabbing the path(s)?
Avatar of jdavistx
jdavistx

And out of curiousity, are you not using:

Directory.GetDirectories(@"YourPathHere", "*", SearchOption.AllDirectories)

Open in new window


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
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of diablo089

ASKER

Substring from dir1 by replacing dir1 with "" (empty string) works for my needs. Thanks guys!