Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove dots from the path in .NET

Tags:

.net

path

How can I convert c:\foo\\..\bar into c:\bar?

like image 915
alex2k8 Avatar asked Jun 09 '09 15:06

alex2k8


People also ask

How to remove dot in c#?

Two ways : string sRaw = "5.32"; string sClean = sRaw. Replace(".", ""); Trim is make for removing leading and trailings characters (such as space by default).

What does dot mean in path?

(dot dot) This refers to the parent directory of your working directory, immediately above your working directory in the file system structure. If one of these is used as the first element in a relative path name, it refers to your working directory.

What is double dot in path?

A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy.

What is C# path?

C# tutorial is a comprehensive tutorial on C# language. The Path is located in the System.IO namespace. With the Path class, we can easily figure out the root path, the directory name of the file, its extension or create a random file name.


2 Answers

string path = Path.GetFullPath("C:\\foo\\..\\bar"); // path = "C:\\bar" 

More Info

like image 132
Randolpho Avatar answered Sep 28 '22 16:09

Randolpho


Have you tried

string path = Path.GetFullPath(@"C:\foo\..\bar"); 

in C# using the System.IO.Path class?

like image 28
Colin Desmond Avatar answered Sep 28 '22 15:09

Colin Desmond