Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenFileDialog hide preview

Tags:

c#

.net

winforms

I have a strange situation where I have an rtf file, that while it opens in word, if I select it in an openfiledialog, then it freezes my .NET app and i have to kill the WINWORD.exe process to regain functionality. This is an issue with the preview pane as when it is hidden, there is no problem.

My call to openfiledialog is bog standard.

using (OpenFileDialog openDialog = new OpenFileDialog() { Title = "Select document...", CheckFileExists = true, Filter = "All files (*.*)|*.*" })
{
    if (openDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) _FileName = openDialog.FileName;
    else return;
}

Other files preview OK, though I anticipate there may be other files may cause a problem, I just haven't found them yet.

As i doubt I can troubleshoot the actual dialog, my workaround is to disable the preview pane - is there any way to do this? of prevent it showing by default?

This is a problem whether the app is run in debug, or standalone.

like image 362
statler Avatar asked Feb 10 '12 03:02

statler


1 Answers

Use the old Windows 95/98 version of the OpenfileDialog that does not have a Preview pane.

To do this, set the openDialog.AutoUpgradeEnabled parameter to false.

like image 76
ulugbek89s Avatar answered Dec 02 '22 14:12

ulugbek89s