Remove "openfiledialog" from C #

4

Good,

I have an OpenFileDialog in my program, but I did not want it to appear when I "open" what is in the image ... If I close the window, it gets "openfiledialog" in the Textbox, and I want it to be blank, since nothing was selected.

Image:

Code:

privatevoidbutton1_Click(objectsender,EventArgse){openFileDialog1.Filter="Request File (*.CSR)|*.csr|Configuration File (*.CNF)|*.cnf";
        DialogResult resposta = openFileDialog1.ShowDialog();
        if (resposta == DialogResult.OK)
        {

            string arquivo = openFileDialog1.FileName;

            VariaveisGlobais.cnf = arquivo;
            VariaveisGlobais.csr = label2.Text;
        }

        textBox3.Text = string.Format("{0}", openFileDialog1.FileName);
        label2.Text = Path.GetFileNameWithoutExtension(openFileDialog1.FileName);
        button2.Enabled = Path.GetExtension(openFileDialog1.FileName) == ".cnf";
        button3.Enabled = Path.GetExtension(openFileDialog1.FileName) == ".csr";
        button4.Enabled = Path.GetExtension(openFileDialog1.FileName) == ".csr";
    }
    
asked by anonymous 29.09.2015 / 10:25

1 answer

5

In your OpenFileDialog instance, before calling the ShowDialog() method, use the FileName property to put the name of a proposed file:

openFileDialogInstance.FileName = "arquivo.txt";

If the name of this file is a bit long, the cursor will stay at the end of the file name, and you can crop the name in the view.

If this happens, use the ShowHelp property to leave the name of the selected file:

openFileDialogInstace.ShowHelp = true;
    
29.09.2015 / 10:47