1

I've searched a lot of threads here at SO, but anything I found was just where the history should be stored and how it could be deleted, like here:

How to clear a FileDialog's dropdown history?

I've looked at the described registry path, but the path where the recent opened files should be stored explained here

View the list of recently opened files in Windows width C#

is missing the last folder OpenSaveMRU on my machine.

Maybe there is the problem already located? How could i solve it?

My OS is Windows 7 x64 with latest available patches.

EDIT 17.12.2013 10:40:

I found out that the OpenSaveMRU key got renamed under Vista/Windows 7 to OpenSavePidlMRU . OpenSaveMRU and LastVisitedMRU


I'm showing the dialog like that:

System.Win32.OpenFileDialog dialog = new System.Win32.OpenFileDialog();
dialog.AddExtension = true;
dialog.CheckPathExists = true;
dialog.DefaultExt = ".xaml";
dialog.Filter = "Xaml files (.xaml)|*xaml|All files|*.*";
dialog.FilterIndex = 0;

Boolean? result = dialog.ShowDialog();
if (result.HasValue && result.Value)
{
   // business logic
}

After opening some files the drop down history still keeps being empty. Any thoughts how to solve this?

The solution is:

The defined filter for xaml has been wrong. There is missing a dot between * and xaml.

Community
  • 1
  • 1
Dom84
  • 852
  • 7
  • 20
  • Try to declare the OpenFileDialog out of method. Reasonably recent list Is in object level, and you create it every time. – dovid Dec 17 '13 at 08:57
  • @lomed well, i tried already declaring dialog object as private member outside my calling method, but it still had the same results. The history doesn't gets displayed. – Dom84 Dec 17 '13 at 08:59

2 Answers2

2

Found it! The problem is this line

Filter = "Xaml files (.xaml)|*xaml|All files|*.*",

Because *xaml is not Extension. Instead Write

Filter = "Xaml files (.xaml)|*.xaml|All files|*.*",
dovid
  • 6,354
  • 3
  • 33
  • 73
1

try use the same dialog object each time:

System.Win32.OpenFileDialog dialog = new System.Win32.OpenFileDialog()
{
    AddExtension = true,
    CheckPathExists = true,
    DefaultExt = ".xaml",
    Filter = "Xaml files (.xaml)|*xaml|All files|*.*",
    FilterIndex = 0
};

private void FileOpen()
{
    Boolean? result = dialog.ShowDialog();
    if (result.HasValue && result.Value)
    {
        // business logic
    }
}
dovid
  • 6,354
  • 3
  • 33
  • 73
  • Thanks but that didn't change the behaviour. I tested it by starting from vs2010 and also starting the executable. I was also wondering how other applications do it because if i look at them, they display the history also after i close and reopen the application. – Dom84 Dec 17 '13 at 09:20
  • i use System.Windows.Forms.OpenFileDialog(), and it show everything, even the first time. You have reason not to use it? – dovid Dec 17 '13 at 09:23
  • No i don't think there could be a reason it was just implemented with that other namespace. I tried it, but it also has no effect :(. I also tried with a completely new WindowsFormsApplication and copy pasted the calling method but its also not displaying the history. – Dom84 Dec 17 '13 at 09:29
  • And in other software, Word for example, history appears? Maybe it is set at the level of the operating system. – dovid Dec 17 '13 at 09:33
  • Yes, Visual Studio, Notepad++ every application which provides an OpenFileDialog is displaying the history. – Dom84 Dec 17 '13 at 09:40
  • i have found the solution. The defined filter for *.xaml Files has been wrong. There is missing a dot between * and the string xaml. O MY GOD :) Thanks for your help and time – Dom84 Dec 17 '13 at 09:49
  • 1
    When you choose "All Files" in drop down filter, it shows the recent files? – dovid Dec 17 '13 at 09:53
  • yes and after correcting the filter information it works for xaml also. – Dom84 Dec 17 '13 at 09:54