Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a path extracted from stored procedure.The path points to a file but i want to traverse one folder up. How should i approach to the problem?
The code for path extracted is:
extractedPath =Convert.ToString( cmd2.ExecuteScalar())
Posted
Updated 17-Jun-14 1:21am
v2

1 solution

C#
using System.IO;
// ...
string x = Path.GetDirectoryName(extractedPath); // containing folder
string y = Path.GetDirectoryName(x); // 1 folder up

y may be null, if x is a root folder (e.g. x = C:\)
 
Share this answer
 
v4
Comments
Anshumaan Chaturvedi 17-Jun-14 7:38am    
Hey that works. Thanks Alexander

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900