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; }
///
/// Config目录
///
public static string ConfigFolder { get; private set; }
///
/// Sqlite数据库目录
///
public static string DatabaseFolder { get; private set; }
///
/// Sqlite数据库Path
///
public static string DatabasePath { get; private set; }
///
/// 多语言目录
///
public static string LangFolder { get; private set; }
///
/// 系统设置目录
///
public static string SettingFolder { get; private set; }
///
/// 参数目录
///
public static string ParameterFolder { get; private set; }
///
/// 参数数据源文件
///
public static string ParameterDataPath { get; private set; }
///
/// 产品数据目录
///
public static string ProductDataFolder { get; private set; }
public static string ProductParameterFolder { get; private set; }
///
/// 产品数据源文件
///
public static string ProductDataFile { get; private set; }
///
/// 测试项数据目录
///
public static string TestItemDataFolder { get; private set; }
///
/// 测试项数据源文件
///
public static string TestItemDataFile { get; private set; }
///
/// sqlite日志数据库文件夹
///
public static string LogViewerDir { 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");
ParameterFolder = InitFolder(ConfigFolder + "\\Parameter");
ParameterDataPath = ParameterFolder + "\\CommonParameter.data";
ProductDataFolder = InitFolder(ConfigFolder + "\\Product");
ProductParameterFolder = InitFolder(ProductDataFolder + "\\Parameter");
ProductDataFile = ProductDataFolder + "\\Product.data";
TestItemDataFolder = InitFolder(ProductDataFolder + "\\TestItem");
TestItemDataFile = TestItemDataFolder + "\\TestItem.data";
LogViewerDir = InitFolder(ConfigFolder + "\\LogViewer");
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 PluginFolder()
{
string Path = RootPath() + "\\Plugin";
return Path;
}
public static string InitFolder(string path)
{
try
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
catch (Exception ex)
{
}
return path;
}
}
}