WPF使用ARCGIS App文件配置Cs后台文件
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后台文件的更多相关文章
- webpack4 单入口文件配置 多入口文件配置 以及常用的配置
单入口文件配置 webpack.config.js const path = require('path'); const HtmlWebpackPlugin = require('html-webp ...
- 虚拟主机ip配置,nginx.conf文件配置及日志文件切割
今天粗略整理了一下虚拟主机配置,nginx.conf文件的配置,及日志文件的切割,记录如下: nginx虚拟主机配置:1.IP地址配置,2.绑定ip地址和虚拟主机详情:1.ip地址的配置:ifconf ...
- maven中pom文件配置解决资源文件的编码问题
<build> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId& ...
- Vue插件配置和 后台交互
Vue插件配置和 后台交互 一.全局配置静态文件(csss, js..) 1.1 全局配置css文件 创建css文件 在main.js配置css文件 // 配置全局css样式 // 方式一 impor ...
- mybatis 自动生成文件配置
maven 依赖配置: <!-- sql server --><dependency> <groupId>com.microsoft.sqlserver</g ...
- Django-03-静态文件配置
一.django静态文件配置原理 静态文件配置就是为了让用户请求时django服务器能找到静态文件返回. 首先要理解几个概念: 媒体文件:用户上传的文件 静态文件:css,js,image等 开发环境 ...
- informatica 参数文件配置
Informatica 中 parameter file 参数文件配置规则: 参数文件的头部内容 [Global] All Integration Services, Integration Serv ...
- Django学习——静态文件配置、request对象方法、pycharm如何链接数据库、Django如何指定数据库、Django orm操作
静态文件配置 # 1.静态文件 网站所使用的已经提前写好的文件 css文件 js文件 img文件 第三方文件 我们在存储静态文件资源的时候一般默认都是放在static文件夹下 # 2.Django静态 ...
- c#Winform程序调用app.config文件配置数据库连接字符串 SQL Server文章目录 浅谈SQL Server中统计对于查询的影响 有关索引的DMV SQL Server中的执行引擎入门 【译】表变量和临时表的比较 对于表列数据类型选择的一点思考 SQL Server复制入门(一)----复制简介 操作系统中的进程与线程
c#Winform程序调用app.config文件配置数据库连接字符串 你新建winform项目的时候,会有一个app.config的配置文件,写在里面的<connectionStrings n ...
随机推荐
- asp.net webform 打造私人后台管理系统(附源码)
系统简介 git地址:https://github.com/qingfengjun/XSSystem 不少人让我做公司的网站,要求不多,但是需要有一个后台系统,所以就有了开发的动力.也想做个系统自己学 ...
- 六十一 Web开发 使用Web框架
由于用Python开发一个Web框架十分容易,所以Python有上百个开源的Web框架.这里我们先不讨论各种Web框架的优缺点,直接选择一个比较流行的Web框架——Flask来使用. 用Flask编写 ...
- ASOP编译说明
具体说明https://source.android.com/source/ 源码下载https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/ 1 搭建编译环境使 ...
- YII2 源码阅读 综述
如何阅读源码呢? 我的方法是,打开xdebug的auto_trace [XDebug] ;xdebug.profiler_append = 0 ;xdebug.profiler_enable = 1 ...
- Codeforces 1099 A. Snowball-暴力(Codeforces Round #530 (Div. 2))
A. Snowball time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Linux下python版本的升级步骤
1.先下载,你要升级的python版本(我升级的是python3.3.0) 可使用系统自带下载工具wget下载: wget http://www.python.org/ftp/python/3.3.0 ...
- 洛谷—— P2562 [AHOI2002]Kitty猫基因编码
P2562 [AHOI2002]Kitty猫基因编码 题目描述 小可可选修了基础生物基因学.教授告诉大家 Super Samuel 星球上 Kitty猫的基因的长度都是 2 的正整数次幂 ), 全是由 ...
- 第2天:Ansible-Inventory管理
在Ansible中,将可管理的服务器集合成为Inventory.因此,Inventory管理便是服务器管理. hosts文件位置 我们知道,Ansible在执行操作时,首先需要确定对哪些服务器执行操作 ...
- 【BZOJ 1052】 1052: [HAOI2007]覆盖问题 (乱搞)
1052: [HAOI2007]覆盖问题 Description 某人在山上种了N棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄 膜把这些小树遮盖起来,经过一番长久的 ...
- BZOJ 4025 二分图(时间树+并查集)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=4025 [题目大意] 给出一张图,有些边只存在一段时间,问在一个每个时间段, 这张图是否 ...