0
Reply

How to save a file after selected it with FileOpenPicker c#

Alessandro De Cristofaris

Alessandro De Cristofaris

Nov 4 2014 4:31 AM
966
I using windows phone silverlight and when run the code in the instruction "StorageFile file = await fileOpenPicker.PickSingleFileAsync();" it generates an exception "The request is not supported", I have already consulted the guide on how to keep an app after calling a method of selecting the file, but it seems that this is only for Windows Phone RunTime.
 
Does anyone know how can I do?
 
This is the code:
 
private async void btn_Crea_Click(object sender, RoutedEventArgs e)
{
    FileOpenPicker openPicker = new FileOpenPicker();
    openPicker.ViewMode = PickerViewMode.Thumbnail;
    openPicker.SuggestedStartLocation = PickerLocationId.VideosLibrary;
    openPicker.ContinuationData["Operation"] = "UpdateVideo";//"UpdateProfilePicture";
    openPicker.FileTypeFilter.Add(".3GP");
    openPicker.FileTypeFilter.Add(".MP4");
    openPicker.FileTypeFilter.Add(".WMV");
    openPicker.FileTypeFilter.Add(".AVI");
    openPicker.FileTypeFilter.Add(".MOV");
    openPicker.FileTypeFilter.Add(".3G2");
    openPicker.PickSingleFileAndContinue();
->StorageFile file = await openPicker.PickSingleFileAsync(); // file represents the video selected by user <-
    if (file != null)
   {
     // Open a stream for the selected file
     Windows.Storage.Streams.IRandomAccessStream fileStream =
                     await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
    // Set the video file
   Singleton.Instance.video = file; // save a video file in the singleton for future use
  }