如何用asp.net+c#删除本地硬盘上的文件?

答5:
private void delwenjian(string filename)
//filename为要下载文件的路径及相应路径下的文件名
{
     FileInfo fi=new FileInfo(filename);
 Response.Clear();
 Response.ClearHeaders();
 Response.Buffer = false;
 Response.ContentType = "application/octet-stream";
 Response.AppendHeader("Content-Disposition","attachment;filename=" +HttpUtility.UrlEncode(fi.FullName,System.Text.Encoding.UTF8));
 Response.AppendHeader("Content-Length",fi.Length.ToString());
 Response.WriteFile(fi.FullName);
 Response.Flush();
 System.IO.File.Delete(filename);
 Response.End();
}

删除服务器端的文件的话就用
System.IO.File.Delete(filename);就可以了
=========================================
来自:http://www.nqqn.com/ym/185/121626.htm

posted @ 2007-07-24 14:09  星空竹月  阅读(447)  评论(2编辑  收藏  举报