Setting the filter to an OpenFileDialog to allow the typical image formats?

I have this code, how can I allow it to accept all typical image formats? PNG, JPEG, JPG, GIF?

Here’s what I have so far:

public void EncryptFile()
{            
    OpenFileDialog dialog = new OpenFileDialog();
    dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
    dialog.InitialDirectory = @"C:\";
    dialog.Title = "Please select an image file to encrypt.";

    if (dialog.ShowDialog() == DialogResult.OK)
    {
        //Encrypt the selected file. I'll do this later. :)
    }             
}

Notice that the filter is set to .txt files. I could change to PNG, but what of the other types?

13 Answers
13

Leave a Comment