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.";
}
}
}