WebApr 4, 2024 · I want to get the path of a folder that is 2 directories up from the current location. I am doing the following: echo %CD% set NEW_PATH = ..\..\bin\ echo %PATH% When I run the above I get the current directory path printed but the NEW_PATH isnt.. It just says ECHO_OFF. WebFeb 21, 2024 · 18 Answers. Sorted by: 120. string mypath = @"..\folder1\folder2\folder2"; string [] directories = mypath.Split (Path.DirectorySeparatorChar); Edit: This returns each individual folder in the directories array. You can get the number of folders returned like this: int folderCount = directories.Length; Share.
Navigate back a folder in C# - Stack Overflow
WebNov 17, 2005 · Get path 2 directories up from some known path Hello, Often times, I am interested in the path of a file within the project's root directory instead of the bin/debug. To get this path, I am using the following code snippet. string path = Environment.CurrentDirectory; string filepath = null; WebJun 13, 2024 · 2 Answers Sorted by: 11 TL;DR run it from the root directory: docker build . -f ./path/to/dockerfile the long answer: in dockerfile you cant really go up. why when the docker daemon is building you image, it uses 2 parameters: your Dockerfile the context fluid challenge hepatorenal syndrome
How to go back n levels of directories from the command line?
WebOct 30, 2024 · This nifty function supports going up in both directions. If you are in /a/b/c/d then 'up 1' will take you to /a/b/c, and so on.Thats pretty standard and covered in most of the other answers. Now, for the special part; using negative numbers takes … WebSep 30, 2016 · myDirectory.Parent.ToString () returns the subfolder's name, not the full path, exactly what I was looking for. In addition, instead of doing Directory.GetParent (Directory.GetParent (str_directory).ToString ()); as showing above, simply using myDirectory.parent.parent.ToString () gets the 'grandparent'. – Weihui Guo. WebYou can use the Path and Directory classes: DirectoryInfo parentDir = Directory.GetParent (Path.GetDirectoryName (path)); string parent = parentDir.FullName; Note that you would get a different result if the path doesn't end with the directory-separator char \. Then images would be understood as filename and not as directory. greenes insurance