• 加载文件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;
    }

  • 相关阅读:
    C++中内联函数
    剑指offer62:二插搜索树的第k个节点
    剑指offer63:数据流中的中位数
    剑指offer64:滑动窗口的最大值
    剑指offer65:矩阵中的路径
    剑指offer66:机器人的活动范围
    kmean算法C++实现
    【数组】Minimum Size Subarray Sum
    【数组】Missing Number
    【数组】Product of Array Except Self
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/2263151.html
Copyright © 2020-2023  润新知