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; }
|
|
/// <summary>
|
/// 应用程序的根目录
|
/// </summary>
|
/// <returns></returns>
|
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;
|
}
|
|
/// <summary>
|
/// 系统配置信息存储文件夹路径
|
/// </summary>
|
/// <returns>系统配置信息文件夹</returns>
|
public static string SystemSettingFolder()
|
{
|
string Path = RootPath() + "\\Config\\SystemSetting";
|
return Path;
|
}
|
|
/// <summary>
|
/// 系统配置文件
|
/// </summary>
|
/// <returns>系统配置文件路径</returns>
|
public static string SystemSettingFile()
|
{
|
string Path = RootPath() + "\\Config\\SystemSetting\\system.setting";
|
return Path;
|
}
|
|
// <summary>
|
/// 菜单配置文件
|
/// </summary>
|
/// <returns>菜单配置文件</returns>
|
public static string MenuFile()
|
{
|
string Path = RootPath() + "\\Config\\SystemSetting\\menu.setting";
|
return Path;
|
}
|
|
/// <summary>
|
/// 生产配置文件夹
|
/// </summary>
|
/// <returns>生产配置文件夹</returns>
|
public static string ProductionFolder()
|
{
|
string Path = RootPath() + "\\Config\\ProductionSetting";
|
return Path;
|
}
|
|
/// <summary>
|
/// 测试项信息存储文件夹
|
/// </summary>
|
/// <returns>测试项存储文件夹</returns>
|
public static string TestItemFolder()
|
{
|
string Path = ProductionFolder() + "\\TestItem";
|
return Path;
|
}
|
|
/// <summary>
|
/// 设置参数文件夹
|
/// </summary>
|
/// <returns>设置参数文件夹</returns>
|
public static string ParameterFolder()
|
{
|
string Path = ProductionFolder() + "\\Parameter";
|
return Path;
|
}
|
|
/// <summary>
|
/// 插件存储目录
|
/// </summary>
|
/// <returns>插件存储目录</returns>
|
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;
|
}
|
}
|
}
|