質問

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.

役に立ちましたか?

解決

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|*.*",

他のヒント

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
    }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top