zoukankan      html  css  js  c++  java
  • 加载文件url下载

            string url = "http://www.youdao.com/n/alliance/images/logo_youdao.gif";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Timeout = 150000;

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            WebHeaderCollection whc = response.Headers;
            Stream stream = response.GetResponseStream();

            Response.Clear();
            Response.ContentType = "application/octet-stream";
            Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("logo_youdao.gif", Encoding.UTF8));


            int buffer = 1024;
            int alreadyRead = 0;
            do
            {
                byte[] bytes = new byte[buffer];
                alreadyRead = stream.Read(bytes, 0, buffer);
                Response.BinaryWrite(bytes);
                Response.Flush();
            }
            while (alreadyRead > 0);
            Response.End();
            Response.Close();

    ----------------------------------------------------------------------------------------------------------------

    protected void Page_Load(object sender, EventArgs e)
    {
    string URl="http://info-database.csdn.net/Upload/2010-12-10/728_90_ty1210.jpg";
    string ss = test(URl);
    }
    string test(string url)
    {
    string PathBigImg = Server.MapPath("~/WebImg/BigImg/") + DateTime.Now.ToString("yyMMddHHmmss") + System.IO.Path.GetExtension(url);

    WebClient wc = new WebClient();
    wc.DownloadFile(url, PathBigImg);

    return PathBigImg;
    }

  • 相关阅读:
    Rman备份及不完全恢复操作
    win2003系统同步Linux ntp server批处理
    ntp服务器搭建
    notepad++调用python3中文乱码
    10G安装DataGuard
    oracle安装配置
    python之路(14)进程
    python之路(13)线程
    python之路(12)网络编程
    python之路(11)描述符
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/2263151.html
Copyright © 2011-2022 走看看