有关文件下载 C#视频 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://188.93.174.57/#q=asp.net+%E6%96%87%E4%BB%B6%E4%B8%8B%E8%BD%BD&newwindow=1&tbs=lr:lang_1zh-CN%7Clang_1zh-TW&lr=lang_zh-CN%7Clang_zh-TW http://blog.csdn.net/codeshark/article/details/2473664 文件下载//检索文件名绑定数据protected void Page_Load(object sender, EventArgs e){ if (!Page.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("Name", typeof(string))); string serverPath = Server.MapPath("File"); DirectoryInfo dir = new DirectoryInfo(serverPath); foreach (FileInfo fileName in dir.GetFiles()) { DataRow dr = dt.NewRow(); dr[0] = fileName; dt.Rows.Add(dr); } ListBox1.DataSource = dt; ListBox1.DataTextField = "Name"; ListBox1.DataValueField = "Name"; ListBox1.DataBind(); }}//选中行索引protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e){ Session["txt"] = ListBox1.SelectedValue.ToString();}//按钮事件完成文件下载protected void LinkButton1_Click(object sender, EventArgs e){ if (Session["txt"] != "") { string path = Server.MapPath("File/") + Session["txt"].ToString(); FileInfo fi = new FileInfo(path); if (fi.Exists) { Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode( fi.Name)); Response.WriteFile(fi.FullName); } }} 第一个就不说了 楼上都说了 对于第二个问题 处理很方便的 你可以存一个加密key 服务器保存这个key并设置有效期另外也可以自己把对应的关键字段和发送时间一起加密 链接回来的时候进行解密判断发送时间 亦或者对加密解密觉得麻烦 直接把时间也进行单独传递 不过加密的验证key需要包括时间 链接回来的时候需要先进行加密验证key的校对 求一方法 定义的 student 索引用不了 读取文件夹中子文件夹的文件 using (DbDataAdapter adapter = this.GetDataAdapter(UpdateBehavior.Standard))问题 问一个省市县城市联动的问题: 如何实现条码枪扫描功能? 请教一个简单的时间问题 关于如何写上传后文件“摘要”内容?? 多线程。窗体控件属性显示的问题 C# Socket服务器和客户端通信问题!!! 求一个简单的正则表达式 谢谢了 这段程序360为什么会 报病毒
//检索文件名绑定数据
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Name", typeof(string)));
string serverPath = Server.MapPath("File");
DirectoryInfo dir = new DirectoryInfo(serverPath);
foreach (FileInfo fileName in dir.GetFiles())
{
DataRow dr = dt.NewRow();
dr[0] = fileName;
dt.Rows.Add(dr);
}
ListBox1.DataSource = dt;
ListBox1.DataTextField = "Name";
ListBox1.DataValueField = "Name";
ListBox1.DataBind();
}
}
//选中行索引
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Session["txt"] = ListBox1.SelectedValue.ToString();
}
//按钮事件完成文件下载
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (Session["txt"] != "")
{
string path = Server.MapPath("File/") + Session["txt"].ToString();
FileInfo fi = new FileInfo(path);
if (fi.Exists)
{
Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode( fi.Name));
Response.WriteFile(fi.FullName);
}
}
}
对于第二个问题 处理很方便的 你可以存一个加密key 服务器保存这个key并设置有效期
另外也可以自己把对应的关键字段和发送时间一起加密 链接回来的时候进行解密判断发送时间
亦或者对加密解密觉得麻烦 直接把时间也进行单独传递 不过加密的验证key需要包括时间 链接回来的时候需要先进行加密验证key的校对