文件讀取,保存
把內(nèi)存-->磁盤
數(shù)據(jù)流stream
包含write()方法,.Read()方法
streamwrite,streamReader可以實(shí)現(xiàn)讀寫
寫入:
using(streamwrite sw=new streamwrite(@"D:\123.txt",true))//true代表追加數(shù)據(jù)bool append
{
sw.write();
sw.Flush();
sw.Close();
}
讀?。?br>using(streamReader sr=new StreamReader(@"D:\123.txt"))
{
sr.ReadToEnd();
sr.Close();
}
用read讀取
using(streamReader sr=new StreamReader(@"D:\123.txt"))
{
byte[]byteArray=new byte[1000];
for(int i=0;i<byteArray.Length;i++)
{
try
{
int temp=sr.Read();
byteArray[i]=byte.parse(temp.Tostring());
}
catch
{
break;
}
this.TextBox.Text=Encoding.UTF8.GetString(byteArray);
}
}
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)
點(diǎn)擊舉報(bào)。