有預定義的選取器
這裏是使用圖像的文件選取器的示例。但是請注意,如果用戶在權限範圍之外選擇文件(來自示例桌面),則只有從選取器返回的StorageFile實例纔有權訪問。
所以你應該保持活着,只要你用這個文件做些什麼。或者你在本地複製它
/// <summary>
///
/// </summary>
/// <param name="identity"></param>
/// <returns></returns>
public static async Task<IStorageFile> FileFromPicker(string identity)
{
FileOpenPicker picker = new FileOpenPicker();
setFileTypes(picker);
picker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
picker.ViewMode = PickerViewMode.Thumbnail;
picker.SettingsIdentifier = identity;
var storageFile = await picker.PickSingleFileAsync();
return storageFile;
}
Thanks @Boas,this is really helpful。 – 2013-03-20 08:33:57