需要详细的解释 特别是红色部分。
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();
}
} --------------------编程问答-------------------- if (System.IO.File.Exists(filePath))
如果文件存在
FileInfo file = new FileInfo(filePath)
定义一个文件信息对象
Response.WriteFile(file.FullName)
把文件写给客户端,实现下载
Response.End()
高速客户端,写完。客户端提示,下载完毕 --------------------编程问答-------------------- 要自己学会查MSDN
--------------------编程问答--------------------
lz不会用Google查么? --------------------编程问答-------------------- 就lz的几行红字,等贴的时间自己也早都查出来了。。。。 --------------------编程问答-------------------- 自己动手解决问题体会更深啦 --------------------编程问答-------------------- 看看msdn
--------------------编程问答--------------------
就是这个样子 --------------------编程问答--------------------
+1 --------------------编程问答--------------------
+! --------------------编程问答--------------------
Random r = new Random();
List<int> lists = new List<int>();
for (int i = 0; i < 100; i++)
{
int k=r.Next(1,100);
if (lists.IndexOf(k) > 0)
{
i--;
}
else
{
lists.Add(k);
}
}
楼主能明白 吗??不明白在问我。。
QQ群 1064 97038 --------------------编程问答-------------------- 回错了。。。
补充:.NET技术 , ASP.NET