Answers for ".net get relative path to project"

C#
0

c# relative path to project folder

string fileName = "ich_will.mp3";
string path = Path.Combine(Environment.CurrentDirectory, @"Data\", fileName);
Posted by: Guest on September-03-2020
0

how to get relative path in c#

Uri file = new Uri(@"c:\foo\bar\blop\blap.txt");
// Must end in a slash to indicate folder
Uri folder = new Uri(@"c:\foo\bar\");
string relativePath = 
Uri.UnescapeDataString(
    folder.MakeRelativeUri(file)
        .ToString()
        .Replace('/', Path.DirectorySeparatorChar)
    );
Posted by: Guest on September-30-2020

C# Answers by Framework

Browse Popular Code Answers by Language