CodePaste Logo
New Snippet New Recent Snippets Recent Snippets My Snippets My Snippets My Favorites Favorites Web Code Search Snippets Search
Sign inor Register
Language: csharp

Read File with Picker in WinRT

1067 Views   
async void Button_Click_1(object sender, RoutedEventArgs e) { // define picker var _Picker = new FileOpenPicker { ViewMode = PickerViewMode.List, SuggestedStartLocation = PickerLocationId.DocumentsLibrary, }; _Picker.FileTypeFilter.Add(".txt"); // let user pick file var _File = await _Picker.PickSingleFileAsync(); if (_File == null) { await new Windows.UI.Popups.MessageDialog("No file").ShowAsync(); return; } // read properties var _Message = string.Format("File date: {0}", (await _File.GetBasicPropertiesAsync()).DateModified); await new Windows.UI.Popups.MessageDialog(_Message).ShowAsync(); // read content var _Content = await Windows.Storage.FileIO.ReadTextAsync(_File); await new Windows.UI.Popups.MessageDialog(_Content).ShowAsync(); }
by Jerry Nixon
  June 29, 2012 @ 12:58pm
Tags:
Add a comment


Report Abuse
brought to you by:
West Wind Techologies