Original: http://www.cnblogs.com/minBear/Archive/2004/08/18/34600.aspx
Get the execution path of the DLL file
When writing a library project, there will often be some special services to use the physical path of the server side. The use of the traditional system.io.directory.getCurrentDirectory () method is Winnt / System32 directory, this is generally not normal. Business needs, and the physical directory where the specific running DLL can be obtained can be obtained by assembly.getexecutingassembly (). CodeBase property, the specific reference method is as follows:
/ ** /
///
Private
String
GetassemblyPath ()
{String _CodeBase = System.Reflection.Assembly.GetExecutingAssembly () CodeBase; _CodeBase = _CodeBase.Substring (8, _CodeBase.Length - 8); // 8 is file:. // The length of the string [] arrSection = _CodeBase.Split ( New char [] {'/'}; string _folderpath = ""; for (int i = 0; i