troubleshooting Question

What can i use when platform not supported for OpenFileDialog in C#

Avatar of Skale
Skale asked on
10 Comments2 Solutions112 ViewsLast Modified:
Hello I'm using below code to get for open file dialog but i'd like to know is there any solution to use different open file dialog can support platform.

So can anyone help me to complete catch section of below code?

                Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog dlg = new Microsoft.WindowsAPICodePack.Dialogs.CommonOpenFileDialog
                    ShowPlacesList = true,
                    Multiselect = false,
                    InitialDirectory = "",
                    IsFolderPicker = false,
                    AddToMostRecentlyUsedList = false,
                    EnsurePathExists = true,
                    EnsureFileExists = true,
                    EnsureValidNames = true,
                    Title = "Open Model"
                    //DefaultDirectory = ""
                    //EnsureReadOnly = false
                    //AllowNonFileSystemItems = false

                dlg.Filters.Add(new Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogFilter("Text Files", "*.txt"));

                if (dlg.ShowDialog() == Microsoft.WindowsAPICodePack.Dialogs.CommonFileDialogResult.Ok)
                    return dlg.FileName;
            catch (System.PlatformNotSupportedException)
                //TODO: Support will added for not supported platforms

            return null;
Eduard Ghergu
Architect - Coder - Mentor

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros