C#獲取當前程式集Assembly的檔名
阿新 • • 發佈:2019-02-17
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"
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"