通过asp.net(c#)从我的网站中删除文件 [英] Delete file from my website by asp.net(c#)
本文介绍了通过asp.net(c#)从我的网站中删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过asp.net(c#)从我的网站中删除文件
嗨
如何通过asp.net(c#)
从我的网站中删除文件
非常感谢
Delete file from my website by asp.net(c#)
Hi
How can I Delete a file from my website by asp.net(c#)
Thanks very much
推荐答案
在单击按钮时尝试以下操作:
Try this on button click event:
using System.IO// add the namesapce
protected void btnSubmit_Click(object sender, EventArgs e)
{
try {
FileInfo TheFile = new FileInfo(MapPath(".") + "\\" + txtFile.Text);
if (TheFile.Exists) {
File.Delete(MapPath(".") + "\\" + txtFile.Text);
}
else {
throw new FileNotFoundException();
}
}
catch (FileNotFoundException ex) {
lblStatus.Text += ex.Message;
}
catch (Exception ex) {
lblStatus.Text += ex.Message;
}
}
希望对您有所帮助:)
hope it helps :)
这篇关于通过asp.net(c#)从我的网站中删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文