using System; using System.IO; namespace HMI.Core.Util { public class PathHelper { public static string AppFolder { get; private set; } = RootPath(); public static string IconFolder { get; private set; } public static string ConfigFolder { get; private set; } public static string DatabaseFolder { get; private set; } public static string DatabasePath { get; private set; } public static string LangFolder { get; private set; } public static string SettingFolder { get; private set; } /// /// 应用程序的根目录 /// /// private static string RootPath() { string DllPath = AppDomain.CurrentDomain.BaseDirectory; string path = Path.GetFullPath("."); IconFolder = InitFolder(path + "\\Icon"); ConfigFolder = InitFolder(path + "\\Config"); DatabaseFolder = InitFolder(ConfigFolder + "\\Database"); DatabasePath = DatabaseFolder + "\\database.db"; LangFolder = InitFolder(path + "\\Lang"); SettingFolder = InitFolder(ConfigFolder + "\\SystemSetting"); return path; } /// /// 系统配置信息存储文件夹路径 /// /// 系统配置信息文件夹 public static string SystemSettingFolder() { string Path = RootPath() + "\\Config\\SystemSetting"; return Path; } /// /// 系统配置文件 /// /// 系统配置文件路径 public static string SystemSettingFile() { string Path = RootPath() + "\\Config\\SystemSetting\\system.setting"; return Path; } // /// 菜单配置文件 /// /// 菜单配置文件 public static string MenuFile() { string Path = RootPath() + "\\Config\\SystemSetting\\menu.setting"; return Path; } /// /// 生产配置文件夹 /// /// 生产配置文件夹 public static string ProductionFolder() { string Path = RootPath() + "\\Config\\ProductionSetting"; return Path; } /// /// 测试项信息存储文件夹 /// /// 测试项存储文件夹 public static string TestItemFolder() { string Path = ProductionFolder() + "\\TestItem"; return Path; } /// /// 设置参数文件夹 /// /// 设置参数文件夹 public static string ParameterFolder() { string Path = ProductionFolder() + "\\Parameter"; return Path; } /// /// 插件存储目录 /// /// 插件存储目录 public static string PluginFolder() { string Path = RootPath() + "\\Plugin"; return Path; } private static string InitFolder(string path) { try { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } } catch (Exception ex) { } return path; } } }