---
lang: ja-jp
breaks: true
---
# WinUI 3 FileOpenPicker/FileSavePicker で SuggestedStartLocation プロパティを設定するとエラーとなる。 2024-03-04
## FileOpenPicker はアプリがこける
```csharp=
var picker = new FileOpenPicker();
picker.FileTypeFilter.Add("*");
picker.FileTypeFilter.Add(".csv");
InitializeWithWindow.Initialize(
picker,
WindowNative.GetWindowHandle(App.MainWindow)
);
// 以下を指定するとアプリがこける。
picker.SuggestedStartLocation = PickerLocationId.Unspecified;
StorageFile storageFile = await picker.PickSingleFileAsync();
```
## FileSavePicker は「指定された SuggestedStartLocation は正しくありません。」とえらーとなる。
```csharp=
var picker = new FileSavePicker();
// Dropdown of file types the user can save the file as
picker.FileTypeChoices.Add("csvファイル", new List<string>() { ".csv" });
// Default file name if the user does not type one in or select a file to replace
picker.SuggestedFileName = $"xxxxxxxx";
InitializeWithWindow.Initialize(
picker,
WindowNative.GetWindowHandle(App.MainWindow)
);
// 「指定された SuggestedStartLocation は正しくありません。」とエラーになる。。
picker.SuggestedStartLocation = PickerLocationId.Unspecified;
StorageFile storageFile = await picker.PickSaveFileAsync();
```
## いろいろやってみたが、ダメ。
###### tags: `WinUI 3` `FileOpenPicker` `FileSavePicker` `SuggestedStartLocation` `エラー`