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. 云平台学习--GitLab

    今天和师父还有孙老师一起,两位大神给我讲了下全世界最先进的云平台架构(Tigzx). 废话不多说,直接说代码的GitLab 第一步: 访问路径:http://git.dlanqi.com:30503, ...

  2. git冲突解决的方法

    在运行时,出现了冲突的报错.类似于<<<<<<< HEAD,在你改变的文件有分支与HEAD间的区别.这里就是冲突的地方. 1.解决方法一 使用命令  切换分支 ...

  3. 跨域请求httpclient

    httpclient:是Apache工具包,util,它可以作为一个爬虫,直接爬取某个互联网上的页面.获取到时页面最终的源文件html.直接可以获取页面返回json.就可以直接在代码内部模拟发起htt ...

  4. PTA L2-002 链表去重 团体程序设计天梯赛-练习集

    L2-002 链表去重(25 分)   给定一个带整数键值的链表 L,你需要把其中绝对值重复的键值结点删掉.即对每个键值 K,只有第一个绝对值等于 K 的结点被保留.同时,所有被删除的结点须被保存在另 ...

  5. Codeforces 1131 F. Asya And Kittens-双向链表(模拟或者STL list)+并查集(或者STL list的splice()函数)-对不起,我太菜了。。。 (Codeforces Round #541 (Div. 2))

    F. Asya And Kittens time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. thinkphp Upload上传文件在客户端生成的临时文件$_FILES['file']['tmp_name']

    1.关于thinkphp 的Upload的$_FILES['file']['tmp_name'] 在使用thinkphp上传图片的时候,在上传的$_FILES数组中,有一个$_FILES['file' ...

  7. 剑指offer-树中两个节点的最低公共祖先

    普通二叉树 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; ...

  8. 按照grouip分组,之后分组调用生成正式凭证 的接口

    按照grouip分组,之后分组调用生成正式凭证 的接口 Map<String, List<OperatingLogVO>> resultMap = new HashMap< ...

  9. POJ 3660 Cow Contest (dfs)

    Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11129   Accepted: 6183 Desc ...

  10. 【Jersey】图片上传及显示

    一.前期准备 图片上传需要用到的一些依赖: <dependency> <groupId>org.jvnet.mimepull</groupId> <artif ...