我是新手,这个是做课件下载的·帮忙注释一下代码·特别是protected void LinkButton2_Click后面的,要很详细很详细的,谢谢各位的帮忙了
protected void LinkButton1_Click(object sender, EventArgs e){
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
string filePath = Server.MapPath("File") + "\\" + Session["txt"].ToString();
if (Session["txt"] != null)
{
if (System.IO.File.Exists(filePath))
{
FileInfo file = new FileInfo(filePath);
Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name)); Response.AddHeader("Content-length", file.Length.ToString());
Response.ContentType = "appliction/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
}
}
protected void ListBox3_SelectedIndexChanged(object sender, EventArgs e)
{
Session["txt"] = ListBox3.SelectedItem.Text.ToString();
}
} --------------------编程问答-------------------- 文件下载,判断文件是否存在。然后调用WriteFile()把文件内容写入客户端。
补充:.NET技术 , C#