How to Get the Local Directory of an Executing Assembly in C#

I used this code in C# to get the local directory of an executing assembly or application.

var uri = new Uri(Assembly.GetAssembly(typeof(MyClass)).CodeBase);
var path = Path.GetDirectoryName(uri.LocalPath);
var outputPath = Path.Combine(path, "MyFolder")

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post
NERV Open Source
Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.