zoukankan      html  css  js  c++  java
  • 服务端自定义下载压缩文件位置

    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();

  • 相关阅读:
    DB开发之oracle存储过程
    DB开发之mysql
    DB开发之oracle
    DB开发之postgresql
    Object-C开发之instancetype和id关键字
    Linux 学习笔记
    Java开发之JDK配置
    Android开发在路上:少去踩坑,多走捷径
    C/C++之Qt正则表达式
    Linux 安全配置指南
  • 原文地址:https://www.cnblogs.com/zxdz/p/13550130.html
Copyright © 2011-2022 走看看