FolderPicker.SuggestedStartLocation 屬性

定義

取得或設定資料夾選擇器尋找要呈現給使用者的資料夾的初始位置。

public:
 property PickerLocationId SuggestedStartLocation { PickerLocationId get(); void set(PickerLocationId value); };
PickerLocationId SuggestedStartLocation();

void SuggestedStartLocation(PickerLocationId value);
public PickerLocationId SuggestedStartLocation { get; set; }
var pickerLocationId = folderPicker.suggestedStartLocation;
folderPicker.suggestedStartLocation = pickerLocationId;
Public Property SuggestedStartLocation As PickerLocationId

屬性值

起始位置的識別碼。

範例

檔案選擇器範例示範如何在檔案選擇器中顯示任何類型的檔案。

這個簡短的程式碼範例示範在要求的位置開啟 FilePicker。

private async void Button_click(object sender, RoutedEventArgs e)
{
    FileOpenPicker filePicker = new FileOpenPicker();
    filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    filePicker.ViewMode = PickerViewMode.List;
    filePicker.FileTypeFilter.Add(".txt");
    StorageFile file = await filePicker.PickSingleFileAsync();
}

備註

SuggestedStartLocation 不一定用來做為資料夾選擇器的開始位置。 為了讓使用者瞭解一致性,資料夾選擇器會記住使用者流覽到的最後一個位置,而且通常會從該位置開始。

適用於