質問

The default Microsoft Office 2010 behavior for persisting the file path of the Open File dialog seems to return to the last place it had been navigated.

  • Open Microsoft Word 2010.
  • Press Ctrl+O.
  • The OpenFileDialog opens to, say, C:\Temp\.
  • Navigate through the file tree to C:\Users\mike\Documents\. Don't select a file, and cancel the operation.
  • Press Ctrl+O again.
  • The dialog will open to the C:\Users\mike\Documents\ directory.

I'd like to duplicate this behavior in my WPF application. However the Microsoft.Win32.OpenFileDialog class doesn't seem to have a way to do this. The dialog returns false if Cancel was pressed (as advertised), but the FileName property doesn't get set if this is the case, and it appears to be impossible to capture the directory.

Any suggestions for how I can do this?

役に立ちましたか?

解決

Thanks to everyone who responded. The answer appears to be that there is no answer.

Thanks to Jim Mischel for this link in the comments, which may provide a start: stackoverflow.com/q/4106120/56778

Also to Hans Passant for his comment 'You'll have to get to the IFileDialogEvents. It isn't entirely impossible but you'll get no help from WPF.'

I have a deadline for which this feature isn't critical, so I'm abandoning this for now. If I ever come up with a solution I'll post it here.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top