c# – Is there a way to use a dialog to open both folders and files?


Well, I'm using openfiledialog to open files, but the software needs to receive files or folders, because it compresses and zips ( .zip ) and then makes a symmetric cipher.

I looked on several sites and the like, and I didn't find a way to use the same dialog to open both types.

private void btn_criptografar_Click(object sender, EventArgs e)
        //Abre o dialogo para abrir arquivos e pastas.
        if (openFileCrypt.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            textBoxShowPath.Text = openFileCrypt.FileName;

            FileStream inStream = File.OpenRead(textBoxShowPath.Text);


It's not possible in the standard control, you have to develop a new one that does this. There is an example of how it can be in a library that works with zip files ( isolated project ).

Another project that does the same .

Scroll to Top