• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

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?


0
gogetsome
Asked:
gogetsome
  • 3
  • 2
1 Solution
 
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

0
 
käµfm³d 👽Commented:
Remove the extra quote in the beginning of line 2  = )
0
 
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 "/"
0
 
käµfm³d 👽Commented:
Sorry, it's GetDirectoryName, not GetDirectory.
0
 
gogetsomeAuthor Commented:
Thanks for your help! Got the last portion with this:
Dim q As String = "/" & s.Substring(s.LastIndexOf("/") + 1)
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now