Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Getting Assembly Path

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 189
    Comment on it

    There are two methods to get assembly path: Method 1:

     Assembly asm = Assembly.GetAssembly(this.GetType());
     string  path = asm.Location;
     string folderPath = Path.GetDirectoryName(path);
    

    Method 2:

    Assembly asm = Assembly.GetAssembly(this.GetType());
    string codeBase = asm.CodeBase;
    UriBuilder uri = new UriBuilder(codeBase);
    string path = Uri.UnescapeDataString(uri.Path);
    string folderPath = Path.GetDirectoryName(path);
    

    As simplicity of Method1 wins over Method2 when NUnit test is not required because Method1 fails sometime during NUnit test.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: