Created
August 6, 2020 23:33
-
-
Save edhebi/c5976a0399b8378def09a774e1672d6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
namespace RealPath | |
{ | |
class Program | |
{ | |
static string RealPath(string path) | |
{ | |
if (!File.Exists(path) && !Directory.Exists(path)) return path; | |
var infos = new DirectoryInfo(path); | |
if (infos.Parent is null) return infos.Name.ToUpper(); | |
var basename = infos.Parent.GetFileSystemInfos(infos.Name)[0].Name; | |
return Path.Combine(RealPath(infos.Parent.FullName), basename); | |
} | |
static void Main(string[] args) | |
{ | |
foreach (string path in args) | |
{ | |
Console.WriteLine(RealPath(path)); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment