資源簡(jiǎn)介
簡(jiǎn)單的小例子,輸入文件路徑后可對(duì)路徑進(jìn)行遍歷并導(dǎo)出到XML,生成Log文件。對(duì)遍歷文件或?qū)С鯴ML不是很理解的話可以參考。只是閑暇時(shí)寫的,并沒有任何校驗(yàn)。內(nèi)含注釋。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.xml.Linq;
using?System.xml;
using?System.IO;
namespace?IO_xml
{
????class?Program
????{
????????///?
????????///?主方法
????????///?
????????///?
????????static?void?Main(string[]?args)
????????{
????????????bool?flag?=?true;
????????????while?(flag)
????????????{
????????????????Console.WriteLine(“除遍歷路徑外,xml和log文件路徑因權(quán)限問題,均不能為C盤。“);
????????????????Console.WriteLine(“請(qǐng)輸入您要遍歷的路徑:“);
????????????????string?path?=?Console.ReadLine();
????????????????Console.WriteLine(“請(qǐng)輸入xml文件的地址:例?d:\\log.xml“);
????????????????string?xmlPath?=?Console.ReadLine();
????????????????Console.WriteLine(“請(qǐng)輸入log文件的地址:例?d:\\log.txt“);
????????????????string?logPath?=?Console.ReadLine();
????????????????TraversalFileAndDirectoryToxml?tfadtx?=?new?TraversalFileAndDirectoryToxml(pathxmlPathlogPath);
????????????????tfadtx.getToxml();
????????????????flag?=?false;
????????????????
????????????}
????????????Console.ReadKey();
????????}
????}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-01-25?14:27??IO_xm
?????目錄???????????0??2013-07-09?14:25??IO_xm
?????文件?????????908??2013-01-25?14:27??IO_xm
?????文件???????37888??2013-07-09?14:24??IO_xm
?????文件?????????187??2013-01-25?14:27??IO_xm
?????文件????????2614??2013-01-25?14:27??IO_xm
?????文件????????1229??2013-01-25?15:34??IO_xm
?????目錄???????????0??2013-01-25?14:27??IO_xm
?????文件????????1424??2013-01-25?14:27??IO_xm
?????文件????????4791??2013-07-08?15:08??IO_xm
評(píng)論
共有 條評(píng)論