Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenFileDialog/c# slow on any file. better solution?

I am opening a file using the OpenFileDialog in c# and I am noticing it is taking between 20-40 seconds to load my file and clear the dialog.

Here is my sample code:

private void btnOpen_Click(object sender, EventArgs e)
{
    if (ofdSettings.ShowDialog() == DialogResult.OK)
    {
         // do nothing
    } 
}

even with this limited example it takes the 20-40 second duration for the dialog to clear. the file i'm selecting is a xml file that is only 1.36kb large

like image 832
rlemon Avatar asked Jul 19 '11 17:07

rlemon


People also ask

What is OpenFileDialog C#?

C# OpenFileDialog control allows us to browse and select files on a computer in an application. A typical Open File Dialog looks like Figure 1 where you can see Windows Explorer like features to navigate through folders and select a file.

What does OpenFileDialog use for?

OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog. OpenFile method, or create an instance of the System.


1 Answers

I had the same problem, openFileDialog1.ShowDialog() was slow, taking 10 seconds after closing it to execute the next line of my program. I noticed in the dialog that I had a couple old shortcuts under "Computer" pointing to webdav url's which were no longer valid. I deleted these shortcuts from windows explorer, and the program is fast now. Check if you have any network connection shortcuts tied to your computer, which also display in the dialog (on the left-hand panel in Windows 7). Try removing them and see if the dialog is faster.

like image 101
Whitzz Avatar answered Oct 05 '22 20:10

Whitzz