Net to get the assembly path, net to get the path

Source: Internet
Author: User

Net to get the assembly path, net to get the path

 

The Assembly loaded from the memory, with no path

 

IIS path

Protectedvoid Page_Load (object sender, EventArgs e)

{

Response. Write ("Assembly path" + System. Reflection. Assembly. GetExecutingAssembly (). Location + "<BR/> ");

Response. Write ("program domain path" + System. AppDomain. CurrentDomain. BaseDirectory + "<BR/> ");

Response. Write ("module path" + System. Diagnostics. Process. GetCurrentProcess (). MainModule. FileName + "<BR/> ");

Response. Write ("RunTime path" + HttpRuntime. BinDirectory + "<BR/> ");

}

 

 

 

Output

 

 

Assembly path C: \ Windows \ Microsoft. NET \ Framework64 \ v4.0.30319 \ Temporary ASP. NET Files \ test \ 02a51a22 \ 1e6b2246 \ assembly \ dl3 \ 3464d812 \ Users \ WebApplication3.dll
Program domain path d: \ Users \ zwx \ Documents \ visual studio 2015 \ Projects \ WebApplication3 \ WebApplication3 \
Module path: c: \ windows \ system32 \ inetsrv \ w3wp.exe
Runtime path d: \ Users \ zwx \ Documents \ visual studio 2015 \ Projects \ WebApplication3 \ WebApplication3 \ bin \

 

 

 

Path in WINFORM

Console. Write ("Assembly path" + System. Reflection. Assembly. GetExecutingAssembly (). Location + "\ r \ n ");

Console. Write ("program domain path" + System. AppDomain. CurrentDomain. BaseDirectory + "\ r \ n ");

Console. Write ("module path" + System. Diagnostics. Process. GetCurrentProcess (). MainModule. FileName + "\ r \ n ");

Console. Write ("RunTime path" + System. Windows. Forms. Application. ExecutablePath + "\ r \ n ");

 

Output

Assembly path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bi

N \ Debug \ ZY.Cloud.Front.GatewayService.exe

Program domain path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bi

N \ Debug \

Module path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bin \

Debug \ ZY.Cloud.Front.GatewayService.exe

Runtime path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bi

N \ Debug \ ZY.Cloud.Front.GatewayService.exe

 

 

Path in Service

Assembly path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bin \ Debug \ ZY.Cloud.Front.GatewayService.exe

Program domain path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bin \ Debug \

Module path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bin \ Debug \ ZY.Cloud.Front.GatewayService.exe

Runtime path D: \ CodeCard \ Front Server \ integrated Front Server \ ZY. Cloud. Front. GatewayService \ bin \ Debug \ ZY.Cloud.Front.GatewayService.exe

 

 

 

When operating files, it is best to display the specified path in the Code. After all, the location of the Assembly itself is uncontrollable. We recommend that you use the program domain path or ExecutablePath.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.