I am able to get the current path through:
Request.PhysicalApplicationPath;
For example, it is C:\consoleapp\capp\files
I want to go up one folder to : C:\consoleapp\capp\
and then to another folder C:\consoleapp\capp\images
How do I do that?
I am able to get the current path through:
Request.PhysicalApplicationPath;
For example, it is C:\consoleapp\capp\files
I want to go up one folder to : C:\consoleapp\capp\
and then to another folder C:\consoleapp\capp\images
How do I do that?
Following should help you to Get to the Parent Directory and then create the new Path based on it.
var path = @"C:\consoleapp\capp\files"; // or in your case Request.PhysicalApplicationPath
var parent = Directory.GetParent(path).FullName;
var newPath = Path.Combine(parent,"Images");
You can read more details on Directory.GetParent() here. Path.Combine allows to you combine multiple strings to path. You can read more on Path.Combine here
Output
parent = C:\consoleapp\capp
newPath = C:\consoleapp\capp\Images
You should use System.IO
You can use DirectoryInfo di = new DirectoryInfo(Directory.GetCurrentDirectory())
and then just use di.Parent
From How to navigate a few folders up?
string path = @"C:\Folder1\Folder2\Folder3\Folder4";
string newPath = Path.GetFullPath(Path.Combine(path, @"..\..\"));
After you navigated up you can attach the new folder again