static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load("./XML.xml");
XmlElement rootElement = null;
XmlNodeList nodeList = doc.SelectNodes("bookstore/book/title");
foreach (XmlNode itemNode in nodeList)
{
Console.WriteLine(itemNode.InnerText);
}
rootElement = doc.DocumentElement;
XmlNodeList bookNodeList = rootElement.SelectNodes("book");
foreach (XmlNode xmlnode in bookNodeList)
{
if (!xmlnode.HasChildNodes)
{
Console.WriteLine(xmlnode.InnerText);
}
else
{
XmlNode titlenode = xmlnode.SelectSingleNode("title");
Console.WriteLine(titlenode.InnerText);
}
}
Console.ReadLine();
class FileDemo
{
//public static void Main(string[] args)
//{
// string path = @"d:\1.txt";
// string content = "www.zklve.com" + DateTime.Now.ToString();
// if (Directory.Exists(path))
// {
// Directory.CreateDirectory(path);
// }
// //写入文件内容
// File.WriteAllText(path, content);
// //文件copy
// string sourcePath = @"d:\2.zip";
// string desPath = @"e:\2.zip";
// File.Copy(sourcePath, desPath);
//}
public static void Main()
{
string[] strArr = new string[5] { "1", "1", "1", "1", "1", };
string path = @"d:\2.zip";
//要写入的流
Stream s = new FileStream(path, FileMode.Open);
byte[] butter = new byte[s.Length];//缓冲区
s.Read(butter, 0, butter.Length);//读取工作
//写入准备
string desPath = @"e:\3.zip";
FileStream fs = new FileStream(desPath, FileMode.Create);
fs.Write(butter,0,butter.Length);
fs.Flush();
fs.Close();
s.Flush();
s.Close();