user1358072
user1358072

Reputation: 447

how to use substring with a file path in c#

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"

Upvotes: 0

Views: 1261

Answers (2)

PVitt
PVitt

Reputation: 11770

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);

Upvotes: 1

D.R.
D.R.

Reputation: 21224

var testPath = System.IO.Directory.GetParent(path);
var newValue = System.IO.Directory.GetParent(testPath);

Upvotes: 11

Related Questions