私の顧客の1人が、ファイルを保存するときにWPFアプリケーションでクラッシュが発生しています。
私の保存ファイルコードは次のとおりです。
var saveFileDialog = new SaveFileDialog {
InitialDirectory = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"\MyApp"),
FileName = "MyFile",
OverwritePrompt = true,
AddExtension = true
};
if (saveFileDialog.ShowDialog() == true) {
...
}
そして、ここに彼らが得ている例外があります:
Value does not fall within the expected range.
A System.ArgumentException occurred
at MS.Internal.Interop.HRESULT.ThrowIfFailed(String message)
at MS.Internal.AppModel.ShellUtil.GetShellItemForPath(String path)
at Microsoft.Win32.FileDialog.PrepareVistaDialog(IFileDialog dialog)
at Microsoft.Win32.FileDialog.RunVistaDialog(IntPtr hwndOwner)
at Microsoft.Win32.FileDialog.RunDialog(IntPtr hwndOwner)
at Microsoft.Win32.CommonDialog.ShowDialog()
(ShowDialog
最後の行のは、上記のコードで行った呼び出しを示しています。)
ですから、私の顧客の場合、Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)を呼び出すと、SaveFileDialog
が気に入らないものが返されInitialDirectory
ます。Web検索(および検証済み)InitialDirectory
で、SaveFileDialogの相対パスを渡すときにこのエラーが発生することがわかりました。Environment.SpecialFolder.MyDocuments
相対パスとして返される可能性はありますか?そうでない場合、誰かが別の潜在的に無効なフォーマットを知っていますか?特定のSpecialFolder.MyDocumentsネットワークパスが原因である可能性がありますか?他のアイデアはありますか?
私は顧客のマシンに直接アクセスできず、顧客は特に技術に精通していないため、何が起こっているのかを100%確実にすることはできません。