alielie
2025-03-13 ba6207f52db76ab47cd6534de0cf1712674ff179
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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;
        }
    }
}