Get part of a string

Hello, I have a string that looks like this:
"~/SurveyImages/Survey - 100727/Tween Deck - UPS Room D2305/Deck, Overhead, Walls, Bulkhead/PICT0147.jpg"

Im populating a datalist with images from this directory: ~/SurveyImages/Survey - 100727/
In the directory there are numerous folders and pitcures within. I need to aquire everything after "~/SurveyImages/Survey - 100727/
and before /PICT0147.jpg"

I will populate a label in the datalist with the resulting string to show the user which folder or where is the directory structure the image can be found.

How can I accomplish this?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
What about this?

string parent = System.IO.Path.GetDirectory("~/SurveyImages/Survey - 100727/Tween Deck - UPS Room D2305/Deck, Overhead, Walls, Bulkhead/PICT0147.jpg");
string cropped = parent.Replace(""~/SurveyImages/Survey - 100727/", string.Empty);

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
Remove the extra quote in the beginning of line 2  = )
gogetsomeAuthor Commented:
Cool, that does get rid of the first portion. How do I get rid of the image portion at the end of the string. My guess is to remove everything after the last "/"
käµfm³d 👽Commented:
Sorry, it's GetDirectoryName, not GetDirectory.
gogetsomeAuthor Commented:
Thanks for your help! Got the last portion with this:
Dim q As String = "/" & s.Substring(s.LastIndexOf("/") + 1)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.