You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
using System;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
|
|
namespace EC.Utils
|
|
{
|
|
public class EnvUtil
|
|
{
|
|
private static string workDirectory;
|
|
|
|
public static void InitWorkDirectory()
|
|
{
|
|
Directory.SetCurrentDirectory(GetWorkDirectory());
|
|
}
|
|
|
|
public static string GetWorkDirectory()
|
|
{
|
|
workDirectory = string.IsNullOrEmpty(workDirectory) ? Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) : workDirectory;
|
|
return workDirectory;
|
|
}
|
|
|
|
public static bool AddDllPath(string dllPath)
|
|
{
|
|
if (!Directory.Exists(dllPath)) { return false; }
|
|
string envPath = Environment.GetEnvironmentVariable("PATH");
|
|
Environment.SetEnvironmentVariable("PATH", envPath + ";" + dllPath);
|
|
return true;
|
|
}
|
|
|
|
public static string CombinePath(string path1, string path2)
|
|
{
|
|
return Path.Combine(path1, path2);
|
|
}
|
|
|
|
public static string CombinePath(params string[] paths)
|
|
{
|
|
return Path.Combine(paths);
|
|
}
|
|
|
|
public static bool ExistFile(string file)
|
|
{
|
|
return File.Exists(file);
|
|
}
|
|
|
|
public static bool ExistDirectory(string dir)
|
|
{
|
|
return Directory.Exists(dir);
|
|
}
|
|
}
|
|
}
|