Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Canonical file names [duplicate]

How to get canonical file name by non-canonical one.

E.g. I want to call function which converts "C:\Program files\..\Windows\aaa.txt" to "C:\Windows\aaa.txt"

I am looking for something like Java File.getCanonicalPath()

like image 205
sergtk Avatar asked Nov 11 '11 09:11

sergtk


Video Answer


1 Answers

You can use the Path.GetFullPath method for this.

Example:

Console.WriteLine(Path.GetFullPath(@"C:\Program files\..\Windows\aaa.txt"));

Output:

C:\Windows\aaa.txt

like image 65
Ani Avatar answered Oct 11 '22 22:10

Ani