加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

[winform]操作文件与xml常用方法

发布时间:2020-12-16 06:33:38 所属栏目:百科 来源:网络整理
导读:bin/debuge下面 1.文件夹移动:log复制到 Log2 System.IO.Directory.Move("Log","Log2"); 2. 判断文件夹是否存在不存在创建文件夹: if (!Directory.Exists("Log")) { Directory.CreateDirectory("Log"); } 3.判断文件是否存在不存在床架文件 DateTime now =

bin/debuge下面

1.文件夹移动:log复制到Log2

System.IO.Directory.Move("Log","Log2");

2.判断文件夹是否存在不存在创建文件夹:

if (!Directory.Exists("Log"))

{

Directory.CreateDirectory("Log");

}

3.判断文件是否存在不存在床架文件

DateTime now = DateTime.Now;

string logFileName = now.ToString("yyyyMMdd") + ".txt";

string fullName = "Log" + logFileName;

if (!File.Exists(fullName))

{

File.Create(fullName);

}

4.打开wod文件

System.Diagnostics.Process proc = new System.Diagnostics.Process();

proc.StartInfo.CreateNoWindow = true;

proc.StartInfo.FileName = @"D:我的XXX.docx";

// proc.StartInfo.Arguments = @"D:我的XXX.docx";

proc.Start();

5.获取路径路径到BIN

System.AppDomain.CurrentDomain.BaseDirectory;

6.CDATA 怎么产生这样的数据?

<XXZY1><![CDATA[郑亚敏1]]></XXZY1>


XmlNode objNode = xmlDocument.DocumentElement.SelectSingleNode("//CommitUnitName");

XmlCDataSection CData = xmlDocument.CreateCDataSection("<郑亚敏");

objNode.InnerXml = "";//清空节点里面的数据

(objNode as XmlElement).AppendChild(CData);


7.修改一个节点的Name值

XmlNode xn = xmlDocument.DocumentElement.SelectSingleNode("//CommitUnitName");

XmlHelper.AppendAttr(xn,"Name","郑亚敏");


<XmlTextTag>

<CommitUnitName Name="郑亚敏22222">

</CommitUnitName>

</XmlTextTag>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读