• 服务端自定义下载压缩文件位置


    Thread t = new Thread((ThreadStart)(() =>{
    SaveFileDialog sfd = new SaveFileDialog();

    //设置文件类型
    sfd.Filter = "(*.zip;*.xls;*.xlsx)|*.et;*.xls;*.xlsx|all|*.*";

    //设置默认文件类型显示顺序
    sfd.FilterIndex = 1;

    //保存对话框是否记忆上次打开的目录
    sfd.RestoreDirectory = true;

    //点了保存按钮进入
    if (sfd.ShowDialog() == DialogResult.OK)
    {
    destinationZipFilePath = sfd.FileName.ToString(); //获得文件路径
    string fileNameExt = destinationZipFilePath.Substring(destinationZipFilePath.LastIndexOf("\") + 1); //获取文件名,不带路径
    // destinationZipFilePath=destinationZipFilePath.Substring(0,destinationZipFilePath.Length- fileNameExt.Length);

    //获取文件路径,不带文件名
    //FilePath = localFilePath.Substring(0, localFilePath.LastIndexOf("\"));

    //给文件名前加上时间
    //newFileName = DateTime.Now.ToString("yyyyMMdd") + fileNameExt;

    //在文件名里加字符
    //saveFileDialog1.FileName.Insert(1,"dameng");

    //System.IO.FileStream fs = (System.IO.FileStream)sfd.OpenFile();//输出文件


    string sourceFilePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Files\" + sourceFileName;

    // destinationZipFilePath = ConfigurationManager.AppSettings["destinationZipFilePath"];
    // destinationZipFilePath += sourceFileName + DateTime.Now.ToString("yyyyMMddHHmmss")+".zip";


    //tag=1 成功
    tag = 1;
    }
    else if (sfd.ShowDialog() == DialogResult.Cancel)
    {
    //已取消保存
    tag = 2;
    }
    else
    {
    //保存失败
    tag = 3;
    }


    }));

    t.SetApartmentState(ApartmentState.STA);
    t.Start();
    t.Join();

  • 相关阅读:
    .NET Core VS Code 环境配置
    系统架构正交分解法
    面向接口可扩展框架之“Mvc扩展框架及DI”
    发送和接收数据包
    Easticsearch通信方式_API
    Web Api集成Swagger
    NET MVC RazorEngine 解析模板生成静态页
    NET单元测试的艺术
    NET平台机器学习组件-Infer.NET
    ActiveMQ相关背景(转)
  • 原文地址:https://www.cnblogs.com/zxdz/p/13550130.html
Copyright © 2020-2023  润新知