The code below can be used to find that base path from other classes, without having to always pass a path parameter from method to method.
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; | |
using System.Reflection; | |
namespace ExampleProject | |
{ | |
public static class OwinUtility | |
{ | |
public static string BasePath | |
{ | |
get | |
{ | |
string basePath = Assembly.GetExecutingAssembly().CodeBase; | |
UriBuilder uri = new UriBuilder(basePath); | |
string fullPath = Uri.UnescapeDataString(uri.Path); | |
return Path.GetDirectoryName(fullPath); | |
} | |
} | |
} | |
} |