Exemplo n.º 1
0
        /// <summary>
        /// 获取设置默认存放目录
        /// </summary>
        /// <param name="defaultDirFlag">设置默认目录标识[true:应用程序目录;false:用户目录;默认为true]</param>
        /// <returns>设置默认存放目录</returns>
        public static string GetDefaultSettingDirectory(bool defaultDirFlag = true)
        {
            string settingDirectory = null;

            if (defaultDirFlag)
            {
                if (string.IsNullOrEmpty(_currentAssemblyDirectory))
                {
                    _currentAssemblyDirectory = ObjectEx.GetAssemblyDirectory <PageGridControlCommon>();
                }

                settingDirectory = System.IO.Path.Combine(_currentAssemblyDirectory, "Setting");
            }
            else
            {
                //获取列设置存放目录
                string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                string appName     = System.IO.Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.FriendlyName);
                //目录格式:appDataPath/appName/Setting/xx.xml
                settingDirectory = System.IO.Path.Combine(appDataPath, appName, "Setting");
            }

            return(settingDirectory);
        }