You can use the System.IO namespace and the Path class to get the current directory of the DLL file in C#. Here's an example:

using System.IO;

string currentDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

This code retrieves the location of the currently executing assembly (the DLL file), and then uses the GetDirectoryName method of the Path class to get the directory name from the assembly location.

Note that this code assumes that you are running it from within the DLL file itself. If you want to get the directory of a different DLL file, you would need to specify the file path instead of using System.Reflection.Assembly.GetExecutingAssembly().Location

get currrent dll directory in C#

原文地址: https://www.cveoy.top/t/topic/ihqU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录