using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; namespace CeramicProjectTool.Util { public class PathUtil { public static string GetAppRootPath() { try { //string strPath = null; //System.Object objPath = Microsoft.Win32.Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\DigiWinCADI", "InstallPath", strPath); //strPath = objPath as string; return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); } catch (System.Exception ex) { string strMsg = ex.Message; MessageBox.Show(strMsg); return Environment.CurrentDirectory; } } private const string FILE_STORE_PATH = "Local/CeramicProject/data/FileStores"; public static string AppRoot { get { string binPath = ""; //binPath = System.Environment.GetEnvironmentVariable("CADI_HOME"); binPath = GetAppRootPath(); if (string.IsNullOrEmpty(binPath)) { binPath = Environment.CurrentDirectory; } //binPath = DynaTeam.Util.Path.GetFormularPath(binPath); _ = System.IO.Directory.CreateDirectory(binPath); binPath = System.IO.Path.GetDirectoryName(binPath) ?? Environment.CurrentDirectory; var appDataPath = System.IO.Path.Combine(binPath, FILE_STORE_PATH); if (!Directory.Exists(appDataPath)) { Directory.CreateDirectory(appDataPath); } return appDataPath; } } } }