資源簡介
簡單的小例子,輸入文件路徑后可對路徑進行遍歷并導出到XML,生成Log文件。對遍歷文件或導出XML不是很理解的話可以參考。只是閑暇時寫的,并沒有任何校驗。內含注釋。

代碼片段和文件信息
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文件路徑因權限問題,均不能為C盤。“);
????????????????Console.WriteLine(“請輸入您要遍歷的路徑:“);
????????????????string?path?=?Console.ReadLine();
????????????????Console.WriteLine(“請輸入xml文件的地址:例?d:\\log.xml“);
????????????????string?xmlPath?=?Console.ReadLine();
????????????????Console.WriteLine(“請輸入log文件的地址:例?d:\\log.txt“);
????????????????string?logPath?=?Console.ReadLine();
????????????????TraversalFileAndDirectoryToxml?tfadtx?=?new?TraversalFileAndDirectoryToxml(pathxmlPathlogPath);
????????????????tfadtx.getToxml();
????????????????flag?=?false;
????????????????
????????????}
????????????Console.ReadKey();
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????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
評論
共有 條評論