• C# 文件操作


    using System.IO;

    Directory.CreateDirectory(FilePath);

    【使用WriteFile下载文件】

    复制代码
    using System.Net

    private
    string fileName = HttpContext.Current.Server.UrlEncode("规范.rar"); private string filePath = HttpContext.Current.Server.MapPath("规范.rar"); //使用WriteFile下载文件 protected void btnDL2_Click(object sender, EventArgs e) {   FileInfo info = new FileInfo(filePath);   long fileSize = info.Length;   Response.Clear();   Response.ContentType = "application/octet-stream";   Response.AddHeader("Content-Disposition", "attachement;filename=" + fileName);   //指定文件大小   Response.AddHeader("Content-Length", fileSize.ToString());   Response.WriteFile(filePath, 0, fileSize);   Response.Flush();   Response.Close(); }
    复制代码
  • 相关阅读:
    [bzoj3524]Couriers
    [bzoj2789]Letters
    [bzoj4318]OSU!
    [luogu4570]元素
    [hdu6600]Just Skip The Problem
    [bzoj5025]单调上升路径
    [bzoj4557]侦察守卫
    [hdu5379]Mahjong tree
    [bzoj2957]楼房重建
    [noi253]A
  • 原文地址:https://www.cnblogs.com/mfryf/p/3701702.html
Copyright © 2020-2023  润新知