zoukankan      html  css  js  c++  java
  • ASP.net资源下载

    protected void downF()
    {
    //判断是否选择文件名
    //获取文件路径
    //string path = Server.MapPath("File/") + Session["file"].ToString();//要下载的资源在本地
    string  path = @"\\192.168.1.90\wwwroot\img.cn-school.com\images\667027ee9425480e8881fd923158317d.png";//要下载的资源在某个服务器
    //初始化 FileInfo 类的实例,它作为文件路径的包装
    FileInfo fi = new FileInfo(path);
    // FileInfo f2 = new FileInfo(path1);
    //判断文件是否存在
    if (fi.Exists)
    {
    //将文件保存到本机上
    Response.Clear();
    Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fi.Name));
    Response.AddHeader("Content-Length", fi.Length.ToString());
    Response.ContentType = "application/octet-stream";
    Response.Filter.Close();
    Response.WriteFile(fi.FullName);
    Response.End();
    }
    else
    {
    Page.RegisterStartupScript("", "<script>alert('请先选择文件名!')</script>");//5~1-a-s-p-x
    }

  • 相关阅读:
    Shell Sort 希尔排序
    Quick Sort 快速排序
    Merge Sort 归并排序
    Insertion Sort
    Bubble Sort
    dubbo的异常栈问题
    IoC 容器
    .Net Core集成RabbitMQ
    .NET CORE Skywalking的集成
    制造业的信息化之路
  • 原文地址:https://www.cnblogs.com/wzq806341010/p/2961855.html
Copyright © 2011-2022 走看看