| | |
| | | using System; |
| | | using System.IO; |
| | | using System.Reflection; |
| | | |
| | | namespace IStation |
| | | { |
| | |
| | | { |
| | | /// <summary> |
| | | /// 根目录 |
| | | /// </summary> |
| | | private static string RootDirectory |
| | | { |
| | | get |
| | | { |
| | | if (string.IsNullOrEmpty(_root_directory)) |
| | | { |
| | | var directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); |
| | | _root_directory = directory.FullName; |
| | | //_root_directory = directory.Root.FullName; |
| | | } |
| | | return _root_directory; |
| | | } |
| | | } |
| | | /// </summary> |
| | | private static string _root_directory; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 独立运行还是嵌入运行 |
| | | /// </summary> |
| | | public static bool IsExeExcute = true; |
| | | |
| | | /// <summary> |
| | | /// 查询数据文件夹路径 |
| | | /// </summary> |
| | | public static string GetRootPath() |
| | | { |
| | | var path = Path.Combine(RootDirectory, Settings.File.DataFolder); |
| | | if (!Directory.Exists(path)) |
| | | Directory.CreateDirectory(path); |
| | | return path; |
| | | { |
| | | if (string.IsNullOrEmpty(_root_directory)) |
| | | { |
| | | if(IsExeExcute) |
| | | { |
| | | var directory = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).FullName; |
| | | _root_directory = Path.Combine(directory, "Data"); |
| | | } |
| | | else |
| | | { |
| | | var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| | | _root_directory = Path.Combine(directory, "Data"); |
| | | } |
| | | } |
| | | return _root_directory; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |