Select file without using OpenFileDialog

-1

Well, last week I asked this question:

Get path from desktop

At this moment I wanted the program in Load, the OpenFileDialog method is used, but without the user having to select the file you want, since the file to be opened in the code would already be implemented. The code I have is this:

Code

 private void CertificateSigningRequest_Load(object sender, EventArgs e)
    {
        **Abre o ficheiro**
        //string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        //string filePath = Path.Combine(desktop, label1.Text + ".cnf");
        //System.Diagnostics.Process.Start(filePath);

        **Quero apenas que ele selecione o ficheiro, mas não abra**
        openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
        openFileDialog1.FileName(label1.Text + ".cnf");
    }

Thank you.

    
asked by anonymous 25.05.2015 / 12:58

1 answer

0

From what I understand, the code loads a digital certificate using an environment variable (in this case, the variable that indicates where the desktop is). The file name is in label1 . Therefore, it is not necessary to use openFileDialog1 :

private void CertificateSigningRequest_Load(object sender, EventArgs e)
{
    string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
    string filePath = Path.Combine(desktop, label1.Text + ".cnf");
    System.Diagnostics.Process.Start(filePath);
}
    
25.05.2015 / 15:52