xml保存基本信息
public static string getXML(string nodeName)
{
string strReturn = "";
try
{
string fileName = Application.StartupPath;
string strFile = fileName + @"\Info.xml";
if (File.Exists(strFile))
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(strFile);
try
{
//根据路径获取节点
XmlNode xmlNode = null;
xmlNode = xdoc.SelectSingleNode("PowerConfig/" + nodeName);
strReturn = xmlNode.InnerText;
}
catch (Exception ee)
{
MessageBox.Show("配置文件异常!");
}
}
else
{
MessageBox.Show("文件有误!请检查确认!");
}
}
catch (Exception ex)
{
MessageBox.Show("获取配置异常!" + ex.Message);
}
return strReturn;
}
public static void setXML(string nodeName, string value)
{
try
{
string fileName = Application.StartupPath;
string strFile = fileName + @"\Info.xml";
if (File.Exists(strFile))
{
XmlDocument xdoc = new XmlDocument();
xdoc.Load(strFile);
try
{
xdoc.SelectSingleNode("PowerConfig/" + nodeName).InnerText = value;
xdoc.Save(strFile); }
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
else
{
MessageBox.Show("文件有误!请检查确认!");
}
}
catch (Exception ex)
{
MessageBox.Show("获取配置异常!" + ex.Message);
}
}
xml保存基本信息的更多相关文章
- poi 读取使用 Strict Open XML 保存的 excel 文档
poi 读取使用 Strict Open XML 保存的 excel 文档 某项目有一个功能需要读取 excel 报表内容,使用poi读取时报错: 具体错误为: org.apache.poi.POIX ...
- 把XML保存为ANSI编码
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlText); //plu.xml 编码是ANSI的.否则称上品名是乱码 XmlEle ...
- Http协议的断点续传下载器,使用观察者模式监视下载进度,使用xml保存下载进度。
下载使用Http协议,为了做到断点续传,在点击暂停后,将已下载的大小等数据通过Json存入xml中,当继续传输的时候从xml文件中读取大小继续下载(好几个月前写的,真的想不起来了) bool CHtt ...
- xml基本操作和保存配置文件应用实例
引言:在实际项目中遇到一些关于xml操作的问题,被逼到无路可退的时候终于决定好好研究xml一番.本文首先介绍了xml的基本操作,后面写了一个经常用到的xml保存配置文件的实例. xml常用方法: 定义 ...
- linq to xml 简单的增、删、改、查、保存xml文件操作
using System; using System.Collections; using System.Configuration; using System.Data; using System. ...
- C++ 操作XML文件 使用MSXML.DLL
使用MSXML.DLL读写XML; 文件顶部加入 #import "msxml3.dll"; using namespace MSXML2; //这两句作用是,在程序的文件夹下生成 ...
- C#操作XML总结
1.using System.Xml; using System.Xml; //初始化一个xml实例 XmlDocument xml=new XmlDocument(); //导入指定xml文件 xm ...
- .net中xml文件的导入使用(包括创建xml和导入xml)
上次有说到.net 创建xml文件的方法(一种固定方式,一种动态方法),这次记录一下怎样导入xml文件 1.导入xml文件的方法 1)xml文件格式
- python处理xml文件
参考:https://docs.python.org/2/library/xml.etree.elementtree.html 例子: <?xml version="1.0" ...
随机推荐
- [Error] ld returned 1 exit status
试试重启你的编译器,不稳定的编译器可能会有这种情况.当然不排除其他原因,若是重启了还不好使,就要看代码哪写错喽!!
- C++学习笔记34:泛型编程拓展3
输入流迭代器 #include <iostream> #include <iterator> #include <algorithm> #include <v ...
- Android之QQ新用户注册界面1
还没到睡觉时间所以再加了一个界面... 问题: 1.下拉列表(因为还没看到这里...) 2.标题栏显示问题 3.按钮的 Enable 设置 .......... 以下是代码: 布局 fragment_ ...
- 2015.10.15class
#include<stdio.h> main() { int a; printf("你的智商是多少?\n"); scanf("%d",&a) ...
- iOS 自定义选项卡-CYLTabBarController
正常的选项卡流程 cocoapods就不说了 创建一个CYLTabBarControllerConfig类 #import <Foundation/Foundation.h> #impor ...
- AndroidStudio 点9图片文件报错
如果项目中不仅9图报错,包含的资源还有一堆不合法PNG,那怎么办???这种情况下,正确的解决办法是找到build.gradle文件,在buildToolsVersion下面加入以下两句: aaptOp ...
- Django 创建APP简单步骤
yum install epel-releaseyum install python34yum install python-pippip install django django-admin st ...
- HDU 1026 Ignatius and the Princess I(带路径的BFS)
http://acm.hdu.edu.cn/showproblem.php?pid=1026 题意:给出一个迷宫,求出到终点的最短时间路径. 这道题目在迷宫上有怪物,不同HP的怪物会损耗不同的时间,这 ...
- JavaScript中reduce()方法
原文 http://aotu.io/notes/2016/04/15/2016-04-14-js-reduce/ JavaScript中reduce()方法不完全指南 reduce() 方法接收 ...
- comboBox 手动输入后回车自动更新数据
C# Winform ComboBox 在输入内容时 会在下拉菜单中显示 根据输入内容查询的结果 2014-01-02 16:42匿名 | 浏览 713 次 C# ComboBox 在输入内容时 会在 ...