赞助连接

赞助连接

阅 读 文 章

要做个http下载文件功能,大家帮助下

[来源:网上转载 (http://bbs.chinaunix.net) | 作者:网友(网络转载) | 时间:2008-05-27 | 浏览: 人次 ]

要做个http下载文件功能,以前都是纯C开发的,现在一点头绪都没有,大家帮助下

给些教程啊,感激ing


官方网站:点击进入
提供多种网站程序:企业站/商城网店/学校/医院/行政/门户/房产/...什么样的都有!
专业网站建设,永久的技术支持,让您无后顾之忧!
联系QQ:812256  183317146  384684725,电话0312-4164045 13613394168


呵呵,应该去请教我们伟大的Google老师。


/*********************
FTP Download and Upload
by netbor
*********************/

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Data.SqlClient;
using System.Security.Cryptography;
using System.Text;
using System.Threading;

public partial class Ftp : System.Web.UI.Page
{
    BaseClass bc = new BaseClass();
    static string path;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            //打开要下载的文件
            string str = this.FileUpload1.PostedFile.FileName;
            string ss = str.Substring(str.LastIndexOf("\\" + 1);
            string s = Server.MapPath("./" + ss);
            path = "ftpfiles\\" + ss;

            string filepath = GridView1.Rows[GridView1.SelectedIndex].Cells[1].Text.ToString();

            string Npath = s + filepath;
            System.IO.FileStream r = new System.IO.FileStream(Npath, System.IO.FileMode.Open);
            //设置基本信息
            Response.Buffer = false;
            Response.AddHeader("Connection", "Keep-Alive";
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(System.IO.Path.GetFileName(Npath), Encoding.UTF
TAG标签 : 大家 帮助 功能 文件 下载 using string // ss Response.Write

最新评论 共有0位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表
网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.newhtm.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.