Get the execution path of the DLL file

xiaoxiao2021-03-06  53

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:

/ ** /

///

/// Get the run path /// ///

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

转载请注明原文地址:https://www.9cbs.com/read-114863.html

New Post(0)