locked
MultiPicker RRS feed

  • Question

  • Hi I am having some problems with an windows store app.
    I need to be able to use a FileOpenPicker
    With PickMultipleFilesAsync and it is working fine when I am copying to a local folder but not when I am copying to RemovableDevices. I have searched the forums and there is no mentioning about it. I have declared it in the appmanifest but it still don’t work. It is strange because it works great in all of the other KnownFolders. Here is some example code.


      private async void BtnBilder_Click(object sender, RoutedEventArgs e)
            {
                if (Windows.UI.ViewManagement.ApplicationView.Value != Windows.UI.ViewManagement.ApplicationViewState.Snapped ||
                                Windows.UI.ViewManagement.ApplicationView.TryUnsnap() == true)
                {
                    Windows.Storage.Pickers.FileOpenPicker openPicker = new Windows.Storage.Pickers.FileOpenPicker();
                    openPicker.CommitButtonText = "Spara";
     
                    openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
                    openPicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
     
                    IReadOnlyList<StorageFile> files;
                    var destinationFolder = await KnownFolders.RemovableDevices.CreateFolderAsync("bilder", CreationCollisionOption.GenerateUniqueName);

                    openPicker.FileTypeFilter.Clear();
                    openPicker.FileTypeFilter.Add(".bmp");
                    openPicker.FileTypeFilter.Add(".png");
                    openPicker.FileTypeFilter.Add(".jpeg");
                    openPicker.FileTypeFilter.Add(".jpg");
     
     
                    files = await openPicker.PickMultipleFilesAsync();
                    if (destinationFolder != null && files != null)
                    {
     
                        foreach (var fileItem in files)
                        {
                            await fileItem.CopyAsync(destinationFolder);
     
                        }
                    }

     

    I really would appreciate your help or if would be so kind to point in the right direction

    Friday, August 23, 2013 12:50 PM

All replies

  • What isn't working?

    Can you provide more details about where this fails, what sort of error you get, and how the actual behavior differs from what you would like?

    Do you have the types you are using declared in your file associations.

    In general it is better to use a FolderPicker to let the user choose where to save things rather than to automatically copy to a specific location. You can have the user set this once and then remember it for later.

    --Rob

    Friday, August 23, 2013 6:08 PM
    Moderator
  • I get this exception when I am copying files to KnownFolders.RemovableDevices
    and only then. If I use any other KnownFolders it works fine. I have declared it in the appmanifest both in the Capabilities and File Type associations

    This is the exception
    An exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll but was not handled in user code
    WinRT information: Unable to create objects in the Storage Folder. This error can occur if the folder is retrieved using a query with grouping options.
    Additional information: Error HRESULT E_FAIL has been returned from a call to a COM compon


    --Krister

    Monday, August 26, 2013 11:29 AM