我需要从特定目录加载库。我想暂时将此文件夹添加到搜索路径中,而不是使用LoadLibrary(Windows)或dlopen(Linux)等特定功能。
所以我有:
public static void AddOrUpdateDllPath(string dllDirectory)
{
dllDirectory = dllDirectory.NormalizePathDelimiters("\\");
var path = "";
switch (RunningPlatform)
{
case OperatingSystem.Windows:
path = "PATH";
Environment.SetEnvironmentVariable(path, Environment.GetEnvironmentVariable(path) + ";" + dllDirectory);
break;
case OperatingSystem.MacOS:
path = "LD_LIBRARY_PATH";
throw new NotImplementedException("How to change " + path);
break;
case OperatingSystem.Linux:
path = "DYLD_FRAMEWORK_PATH";
throw new NotImplementedException("How to change " + path);
break;
}
}
我不知道如何为Linux和MaxOS添加路径变量?