和Java一樣
//C#寫入/讀出文本文件
string fileName =@
StreamReader sr = new StreamReader(fileName); string str=sr
StreamWriterrw=File
rw
rw
rw
rw
rw
//打開文本文件
StreamReadersr=File
StringBuilderoutput=newStringBuilder();
stringrl;
while((rl=sr
output
}
lblFile
sr
//C#追加文件
StreamWritersw=File
sw
sw
sw
sw
sw
//C#拷貝文件
stringOrignFile
OrignFile=Server
NewFile=Server
File
//C#刪除文件
stringdelFile=Server
File
//C#移動文件
stringOrignFile
OrignFile=Server
NewFile=Server
File
//C#創建目錄
//創建目錄c:sixAge
DirectoryInfod=Directory
//d
DirectoryInfod
//d
DirectoryInfod
//將當前目錄設為c:sixAge
Directory
//創建目錄c:sixAgesixAge
Directory
//創建目錄c:sixAgesixAge
Directory
能實現文件的讀操作
StreamReader sr = new StreamReader(fileName
From:http://tw.wingwit.com/Article/program/net/201311/12725.html