using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows; using ESRI.ArcGIS.esriSystem;
using System.Xml.Serialization;
using System.IO;
using SWGW.Properties;
using System.Diagnostics;
namespace SWGW
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{ #region License
protected override void OnStartup(StartupEventArgs e)
{
SettingsManager.OnStartup();
base.OnStartup(e); if (!LicenseManager.InitializeLicense.InitializeEngineLicense())
{
MessageBox.Show("无法初始化ArcGIS Engine的授权或地球扩展。截止...");
} }
#endregion #region 私有类
static class SettingsManager
{
#region Class Members
static Settings settings = new Settings();
const string applicationDirectory = "SWGW";
//配置文件名称
const string settingsFileName = "XXXX.xml";
#endregion Class Members #region Constructor static SettingsManager()
{
EnsureDirectoryExists();
} #endregion Constructor #region Properties public static Settings ApplicationSettings
{
get { return settings; }
} #endregion Properties #region Startup, Exit public static void OnStartup()
{
LoadSettings();
} public static void OnExit()
{
SaveSettings();
} #endregion Overrides #region Other Functions static string SettingsFileName
{
get
{
return Path.Combine(
Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
applicationDirectory),
settingsFileName);
}
} static void LoadSettings()
{
Settings tmp; try
{
XmlSerializer xml = new XmlSerializer(typeof(Settings)); using (Stream stream = new System.IO.FileStream(SettingsFileName,
FileMode.Open, FileAccess.Read, FileShare.Read))
{
tmp = (Settings)xml.Deserialize(stream);
}
}
catch (Exception e)
{
Trace.WriteLine(e.Message);
return;
} settings = tmp;
} static void SaveSettings()
{
try
{
XmlSerializer xml = new XmlSerializer(typeof(Settings)); using (Stream stream = new System.IO.FileStream(SettingsFileName,
FileMode.Create, FileAccess.Write, FileShare.None))
{
xml.Serialize(stream, settings);
}
}
catch (Exception e)
{
Trace.WriteLine(e.Message);
}
} [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
static void EnsureDirectoryExists()
{
try
{
DirectoryInfo info = new DirectoryInfo(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
applicationDirectory)); if (!info.Exists)
{
info.Create();
}
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
}
} #endregion Other Functions
} #endregion
}
}

WPF使用ARCGIS App文件配置Cs后台文件的更多相关文章

  1. webpack4 单入口文件配置 多入口文件配置 以及常用的配置

    单入口文件配置 webpack.config.js const path = require('path'); const HtmlWebpackPlugin = require('html-webp ...

  2. 虚拟主机ip配置,nginx.conf文件配置及日志文件切割

    今天粗略整理了一下虚拟主机配置,nginx.conf文件的配置,及日志文件的切割,记录如下: nginx虚拟主机配置:1.IP地址配置,2.绑定ip地址和虚拟主机详情:1.ip地址的配置:ifconf ...

  3. maven中pom文件配置解决资源文件的编码问题

    <build> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId& ...

  4. Vue插件配置和 后台交互

    Vue插件配置和 后台交互 一.全局配置静态文件(csss, js..) 1.1 全局配置css文件 创建css文件 在main.js配置css文件 // 配置全局css样式 // 方式一 impor ...

  5. mybatis 自动生成文件配置

    maven 依赖配置: <!-- sql server --><dependency> <groupId>com.microsoft.sqlserver</g ...

  6. Django-03-静态文件配置

    一.django静态文件配置原理 静态文件配置就是为了让用户请求时django服务器能找到静态文件返回. 首先要理解几个概念: 媒体文件:用户上传的文件 静态文件:css,js,image等 开发环境 ...

  7. informatica 参数文件配置

    Informatica 中 parameter file 参数文件配置规则: 参数文件的头部内容 [Global] All Integration Services, Integration Serv ...

  8. Django学习——静态文件配置、request对象方法、pycharm如何链接数据库、Django如何指定数据库、Django orm操作

    静态文件配置 # 1.静态文件 网站所使用的已经提前写好的文件 css文件 js文件 img文件 第三方文件 我们在存储静态文件资源的时候一般默认都是放在static文件夹下 # 2.Django静态 ...

  9. c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程

    c#Winform程序调用app.config文件配置数据库连接字符串 你新建winform项目的时候,会有一个app.config的配置文件,写在里面的<connectionStrings n ...

随机推荐

  1. 【笔试题】Spring笔试题

    spring笔试题 1.Spring支持的事务管理类型 Spring支持两种类型的事务管理: 编程式事务管理:这意味你通过编程的方式管理事务,给你带来极大的灵活性,但是难维护. 声明式事务管理:这意味 ...

  2. Qt精简编译方法总结

    原文请看:http://blog.csdn.net/loaden/article/details/6061702 Qt如果采取默认编译安装,一般都要占用上G的空间.当初自己不想涉及Qt的一个原因,就是 ...

  3. [已解决]#1142 - SELECT command denied to user ''@'localhost' for table 'pma_table_uiprefs'

    症状:在phpmyadmin那边打不开表,提示 #1142 - SELECT command denied to user ''@'localhost' for table 'pma_table_ui ...

  4. thinkphp的where方法的使用

    1.Thinkphp中where()条件的使用 总是有人觉得,thinkphp的where()就是写我要进行增加.查询.修改.删除数据的条件,很简单的,其实我想告诉你,where()是写条件语句的,但 ...

  5. Java工具类-加密算法

    import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.securit ...

  6. 大数据技术之_16_Scala学习_05_面向对象编程-中级

    第七章 面向对象编程-中级7.1 包7.1.1 Java 中的包7.1.2 Scala 中的包7.1.3 Scala 包的特点概述7.1.4 Scala 包的命名7.1.5 Scala 会自动引入的常 ...

  7. Implement Trie(LintCode)

    Implement Trie Implement a trie with insert, search, and startsWith methods. 样例   注意 You may assume ...

  8. 单例(LintCode)

    单例 单例 是最为最常见的设计模式之一.对于任何时刻,如果某个类只存在且最多存在一个具体的实例,那么我们称这种设计模式为单例.例如,对于 class Mouse (不是动物的mouse哦),我们应将其 ...

  9. 【Java多线程】线程池学习

    Java线程池学习 众所周知,Java不仅提供了线程,也提供了线程池库给我们使用,那么今天来学学线程池的具体使用以及线程池基本实现原理分析. ThreadPoolExecutor ThreadPool ...

  10. Knockout.js(一):简介

    Knockout是一款很优秀的JavaScript库,通过应用MVVM模式使JavaScript前端UI简单化.任何时候你的局部UI内容需要自动更新,KO都可以很简单的帮你实现,并且非常易于维护. K ...