0

I know this value should be used Substring but i am not sure how to do this in C#. Your given code much appreciated. thanks!

What i want to change this :

   "C:\\TFS\\Deployment\\files\\1.0.1.1\\test\\test00.xml"

to new value:

   "C:\\TFS\\Deployment\\files\\1.0.1.1"
4
  • 3
    Have you checked the documentation? It's supposed you open and read the page. Commented Aug 1, 2013 at 12:28
  • Have a look at this Commented Aug 1, 2013 at 12:30
  • msdn.microsoft.com/en-us/library/aka44szs(v=vs.100).aspx Commented Aug 1, 2013 at 12:32
  • 1
    do you have to use substring? Path manipulation is usually most easily done with methods designed for paths (see D.R.'s answer for example). Commented Aug 1, 2013 at 12:32

2 Answers 2

11
var testPath = System.IO.Directory.GetParent(path);
var newValue = System.IO.Directory.GetParent(testPath);
Sign up to request clarification or add additional context in comments.

Comments

1

Well, it's hard to determine what criteria is used to truncate the string. Besides D.R.'s answer:

"C:\\TFS\\Deployment\\files\\1.0.1.1\\test\\test00.xml".Substring(0,31);

1 Comment

@user1358072 I'm quite shocked that this is what you were looking for. This is the result of reading the documentation and counting characters. And counting the characters should not be the criteria of choice when it comes to split strings...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.