C#获取当前程序集Assembly的文件名
作者:C/S框架网  发布日期:2017-10-07 19:58:15
  C#获取当前程序集Assembly的文件名

C# Code:

string codeBase = Assembly.GetExecutingAssembly().GetName().CodeBase;
返回结果:"file:///c:/users/administrator/documents/visual studio 2015/Projects/WindowsFormsApplication4/WindowsFormsApplication4/bin/Debug/WindowsFormsApplication4.EXE"

string file = Assembly.GetExecutingAssembly().GetName().Name;
返回结果:"WindowsFormsApplication4"

string location = Assembly.GetExecutingAssembly().Location;
返回结果:"c:\\users\\administrator\\documents\\visual studio 2015\\Projects\\WindowsFormsApplication4\\WindowsFormsApplication4\\bin\\Debug\\WindowsFormsApplication4.exe"

string fileName = Path.GetFileName(Assembly.GetExecutingAssembly().Location);
返回结果:"WindowsFormsApplication4.exe"

//来源:C/S框架网(www.csframework.com) QQ:23404761


上一篇 下一篇