下载文件时需要一个对话框 [英] Need a dialogue box when I download a file

查看:69
本文介绍了下载文件时需要一个对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨伙计,



我需要在控制台应用程序中提供下载窗口。我正在查询db并将结果集存储在PDF中。我也使用pd4ml.dll将流转换为PDF,但它不允许我提供弹出窗口。



请建议。



问候,

Pramod V

Hi Folks,

I have a requirement to provide a download window in a Console application. I am querying db and storing the resultset in a PDF. I am also using a pd4ml.dll for converting stream to PDF, but it does not allow me to provide a pop up.

Please suggest.

Regards,
Pramod V

推荐答案

希望这能解决您的问题。在下面的示例中,我从控制台应用程序打开一个folderbrowsedialog,并显示完整的选定路径以及文件名。您使用相同的方法从用户获取文件夹路径并将文件下载到该位置。



添加对System.Windows.Forms项目的引用



Hope this solves your problem. In the below example I am opening a folderbrowsedialog from a console app and displaying the full selected path along with file name. You use the same to get the folder path from user and download the file to that location.

Add a reference of to your System.Windows.Forms project

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms; 

namespace Demo1
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            string fileName="file1";

            Console.WriteLine(OpenFolder() + "\\" + fileName);

            Console.Read();
        }
       
        
       public static string  OpenFolder()
        {
            FolderBrowserDialog fd = new FolderBrowserDialog();
            
            DialogResult result = fd.ShowDialog();
            if (result == DialogResult.OK)
            {
                return fd.SelectedPath;
            }
            return string.Empty;
        }

   }
}


这篇关于下载文件时需要一个对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆