Get Directory Path - CSharp System.Reflection

CSharp examples for System.Reflection:Assembly

Description

Get Directory Path

Demo Code


using System.Reflection;
using System.IO;/*from  w w w .  j  a v  a2 s. c o m*/
using System;

public class Main{
        internal static string GetDirectoryPath(this Assembly assembly)
        {
            var codeBase = assembly.CodeBase;
            var uri = new UriBuilder(codeBase);
            var path = Uri.UnescapeDataString(uri.Path);
            return Path.GetDirectoryName(path);
        }
}

Related Tutorials