Search code examples
c#openfiledialog

OpenFileDialog does sometimes show empty navigation


I show an OpenFileDialog with the following code:

var fileBox = new Microsoft.Win32.OpenFileDialog
{
    InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
    Filter = "All files (*.*)|*.*",
    FilterIndex = 1,
    Multiselect = true,
    CheckPathExists = true,
    CheckFileExists = true
};
var fileSelected = fileBox.ShowDialog(owner);

Mostly this works perfectly. But from time to time, the navigation at the left in the Dialog is shown as white rectangle. You can see that in this printscreen:

enter image description here

Does someone have an idea, why this appears?


Solution

  • Hmm... Not quite sure as to why this happens. Some sources say that the permission of a user might contribute, some people had to reboot stuff but most times the cause is that there is an inaccurate execution of codes by the system. So I'll suggest that you input a path yourself eg: openFileDialog.InitialDirectory = @"C:\Users\owner\Documents\";

    or if you're unsure of what drive(eg. C:) or user(eg: owner) will be using the system, you can obtain this information and concatenate or so. Hope this helps slightly.