views:

169

answers:

1

I have made a WPF application on which you can open some Open/SaveFileDialogs. On my PC it remembers the directory I was in last time I used such a dialog and sets that as initial directory when I open another such dialog. But on my colleague's PC it doesn't remember.

The exact class I use is Microsoft.Win32.OpenFileDialog. We both have WinXP installed.

What could be causing this?

UPDATE: Apparently this issue is not resolved yet. I found out that it also happens on my PC. I found when I select multiple files and the click open or press enter, then it doesn't save the location where it was. But when I select only one file and clock open or press enter (or double click on it), then it does remember the location.

Here's the code:

public override void Execute(object parameter) 
{
    OpenFileDialog dialog = new OpenFileDialog();
    dialog.DefaultExt = ".txt";
    dialog.Filter = "Text files (.txt)|*.txt";
    dialog.Multiselect = true;
    dialog.Title = "Select a trace file";
    // The documentation says ShowDialog always returns either true or false, 
    // so we get the value of the returned Nullable<bool> immediately to get 
    // rid of the Nullable<bool> type.
    bool result = dialog.ShowDialog().Value;
    if (result)
    {
        foreach (string fileName in dialog.FileNames)
        {
            traceFilesViewModel.TraceFileList.Add(fileName);

            traceFilesViewModel.StatusBackground = Brushes.PeachPuff;
            traceFilesViewModel.StatusForeground = Brushes.Red;
            traceFilesViewModel.StatusText = "Trace files not loaded.";
        }
    }
}
+3  A: 

The things that could make the OpenFileDialog "forget" the last used directory are :

  • the folder has been moved/renamed
  • the user doesn't have rights for reading the folder anymore
  • the system drive (containing user profiles) is full and the user's profile cannot be properly stored on the local machine
  • the application is executed from a remote location and this location is not considered as trusted (eg : \server\deployment\myapp.exe)

I hope it helps.

Manitra Andriamitondra
Thank you for these hints. The last one is a very likely candidate. I will investigate.
Matthijs Wessels