3
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");

StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
    // Application now has read/write access to the picked file
    OutputTextBlock.Text = "Picked photo: " + file.Name;
}
else
{
    OutputTextBlock.Text = "Operation cancelled.";
}


ファイルピッカーにすべてのファイルタイプを表示する手段を追加するにはどうすればよいですか?openPicker.FileTypeFilter.Add(".*");

4

1 に答える 1

4

あなたはほとんどそこにいます..正しい構文はopenPicker.FileTypeFilter.Add("*");

FileTypeFilterドキュメントから:

ファイル ピッカーのサンプルは、ファイル ピッカーに任意の種類のファイルを表示して、ユーザーが選択できるようにする方法を示しています。

サンプルのコードは次のとおりです。

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
openPicker.FileTypeFilter.Add("*");
于 2012-10-06T07:49:15.377 に答える