高清国产av一区二区三区_亚洲欧美日韩在线_无码熟妇人妻av在线影片免费_在线无码一级伊伊_爽好舒服高H自慰软件_亚洲熟女区偷拍区高清区_午夜福利影院啪啪_亚洲国产黄片在线播放_中文字幕日韩精品乐乐影院_久久国产亚洲日韩欧美精品

掃描二維碼關(guān)注

首頁 APP開發(fā)小程序開發(fā) 微信公眾號(hào) 網(wǎng)站建設(shè) 營銷推廣 經(jīng)典案列 產(chǎn)品服務(wù) 關(guān)于我們

“學(xué)習(xí)不僅是掌握知識(shí)”

向書本學(xué)習(xí),還要向?qū)嵺`學(xué)習(xí)、向生活學(xué)習(xí)。消化已有知識(shí),
而且要力求有所發(fā)現(xiàn)、有所發(fā)明、有所創(chuàng)造

.NET文件操作

2019/3/24 8:18:11

.NET文件操作

文件的建立

源代碼:
private void Button1_Click(object sender, System.EventArgs e)
{
//string wenjian;
//wenjian = filename.Text;
if (this.filename.Text.ToString().Trim()=="")
{
this.body.Text = "********";
}
else
{
try
{
string thisfilename=filename.Text.ToString();
FileStream fsMyfile = new FileStream(thisfilename,FileMode.Create,FileAccess.ReadWrite);
fsMyfile.Close();
this.body.Text = "********";
}
catch
{
//Console.WriteLine("{0} Second exception caught.", e);

this.body.Text = "********";

}
}

} 


文件的刪除

源代碼:


private void Button4_Click(object sender, System.EventArgs e)
{
if (this.filename.Text.ToString().Trim()=="")
{
this.body.Text = "********";
}
else
{
try
{
string thisfilename=filename.Text.ToString();

File.Delete(thisfilename);
this.body.Text = "********";

}
catch
{
//Console.WriteLine("{0} Second exception caught.", e);

this.body.Text = "********";

}


}

}

文件的讀取

源代碼:


private void Button2_Click(object sender, System.EventArgs e)

{
if (this.filename.Text.ToString().Trim()=="")
{
this.body.Text = "請(qǐng)選擇文件名稱!";
}
else
{
try
{


string thisfilename=filename.Text.ToString();
StreamReader srMyfile = new StreamReader(thisfilename);
srMyfile.BaseStream.Seek(0,SeekOrigin.Begin);
string sl;
sl = srMyfile.ReadToEnd();
this.body.Text = sl;
srMyfile.Close();
}
catch
{
//Console.WriteLine("{0} Second exception caught.", e);

this.body.Text = "此文件不存在!";

}

}

}

文件的寫入

源代碼:


private void Button3_Click(object sender, System.EventArgs e)
{
if (this.filename.Text.ToString().Trim()=="")
{
this.body.Text = "********";
}
else
{
try
{
string thisfilename=filename.Text.ToString();
StreamWriter swMyfile = new StreamWriter(thisfilename);
string xieru = body.Text.ToString();
swMyfile.WriteLine(xieru);
swMyfile.Flush();
swMyfile.Close();
this.body.Text = "********";

}
catch
{
//Console.WriteLine("{0} Second exception caught.", e);

this.body.Text = "********";

}


}
 


深圳市南山區(qū)南山街道南海大道西桂廟路北陽光華藝大廈1棟4F、4G-04

咨詢電話:136 8237 6272
大客戶咨詢:139 0290 5075
業(yè)務(wù)QQ:195006118
技術(shù)QQ:179981967

精銳軟件

Copyright? 2018-2023 深圳精銳軟件技術(shù)有限公司 All Rights Reserved. ICP備案號(hào):粵ICP備18108116號(hào)-8 公安備案號(hào):粵公網(wǎng)安備44030502009460號(hào)