[winform]操作文件与xml常用方法
2014-12-19 19:20
423 查看
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="郑亚敏11111">
</CommitUnitName>
</XmlTextTag>
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="郑亚敏11111">
</CommitUnitName>
</XmlTextTag>
相关文章推荐
- c#操作XML常用方法
- 简单的VC 操作XML 文件的的方法
- C# winform程序发布后找不到数据文件(xml,ini,etc...)的解决方法
- c# winform app.config xml 配置文件 读写操作
- c#对xml文件常用操作
- xml文件操作小结(3)---selectsinglenode方法中的xpath%%%%转自酷网动力(www.ASPCOOL.COM)。
- php文件操作常用函数或方法
- delphi 生成xml 方法 与 delphi txt文件操作
- 简单的VC 操作XML 文件的的方法
- C#操作xml配置文件最简单方法
- C#中常用的经典文件操作方法
- C#中常用的经典文件操作方法
- C#中常用的文件操作方法
- xml文件操作技巧---selectsinglenode方法中的xpath%%%%
- 简单的VC 操作XML 文件的的方法
- ASP.NET中的文件操作常用方法
- 简单的VC 操作XML 文件的的方法
- Dom操作xml的常用方法
- delphi 生成xml 方法 与 delphi txt文件操作
- Dom操作xml的常用方法