Hello,
Let’s take this string has an example:
D:/firstdir/Another One/and 2/bla bla bla/media/reports/Darth_Vader_Report.pdf
I want to cut the first part of the path:
D:/firstdir/Another One/and 2/bla bla bla
And replace it with **../**
, and keep the second part of the path
(media/reports/Darth_Vader_Report.pdf
)
If I knew the length or size of it, I could use the Replace
or Substring
. But since the first part of the string is dynamic, how can I do this?
Update
After StriplingWarrior question, I realized that I could have explained better.
The objective is to replace everything behind /media
. The “media” directory is static, and will always be the decisive part of the path.