开发者

How to give userchoice file name in browserdialog box

开发者 https://www.devze.com 2023-04-10 11:32 出处:网络
Hi in my windows form application i want to save some data in a folder and when user selcts the browse button it should browse to reqired folder and should consist of a textbox to enter the filename o

Hi in my windows form application i want to save some data in a folder and when user selcts the browse button it should browse to reqired folder and should consist of a textbox to enter the filename of user choice. How can i achieve this . The below code is not working for me

      private void OutputFolder_button_Click(object sender, EventArgs e)
    {


        FolderBrowserDialog fd = new FolderBrowserDialog();

        try
        {
            if (fd.ShowDialog() == DialogResult.OK)
            {

                if (string.IsNullOrEmpty(OutputFolder.Text))
                {
                    MessageBox.Show(" Please provide output file to do backup ");
                    return;
       开发者_JS百科         }
                outputFileName = fd.SelectedPath + "\\" + outputFileName;
                File.Create(outputFileName).Dispose();
                OutputFolder.Text = outputFileName;
                //File.Create(outputFileName);
                DisplayMainWindow("Selected path to backup" + outputFileName);
                Logger.Log("Selected path to backup" + outputFileName);
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("Exception" + ex);

    }


Sounds like you need the SaveFileDialog class.


You need a SaveFileDialog.

The example in the MSDN page should be enough to get you started.

0

精彩评论

暂无评论...
验证码 换一张
取 消