コード例 #1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            FolderPicker fp = new FolderPicker();

            fp.FileTypeFilter.Add("*");
            fp.SuggestedStartLocation = PickerLocationId.Desktop;
            fp.ViewMode = PickerViewMode.Thumbnail;
            var files = await fp.PickSingleFolderAsync();

            iol = await files.GetFilesAsync();

            //IReadOnlyList<StorageFolder> file = iol
            Myobj myobj = new Myobj();
            ObservableCollection <Myobj> datasource = new ObservableCollection <Myobj>();

            //Windows.Storage.Streams.IRandomAccessStream iras = await sf.OpenAsync(FileAccessMode.Read);
            sf = iol[0];
            //IReadOnlyList<IStorageFile> file = ;
            foreach (StorageFile a in iol)
            {
                myobj.Name = sf.DisplayName.ToString();
                //gw.DisplayMemberPath = "Name";
                var tn = await sf.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView);

                BitmapImage bi = new BitmapImage();
                bi.SetSource(tn);
                myobj.Thumbnail = bi;
                datasource.Add(myobj);
            }
            this.gw.ItemsSource = datasource;
            //  gw.DisplayMemberPath = "data";
        }
コード例 #2
0
 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     FolderPicker fp = new FolderPicker();
     fp.FileTypeFilter.Add("*");
     fp.SuggestedStartLocation = PickerLocationId.Desktop;
     fp.ViewMode = PickerViewMode.Thumbnail;
     var files = await fp.PickSingleFolderAsync();
     iol = await files.GetFilesAsync();
    //IReadOnlyList<StorageFolder> file = iol
     Myobj myobj = new Myobj();
     ObservableCollection<Myobj> datasource = new ObservableCollection<Myobj>();
    //Windows.Storage.Streams.IRandomAccessStream iras = await sf.OpenAsync(FileAccessMode.Read);
    sf = iol[0];
    //IReadOnlyList<IStorageFile> file = ;
    foreach (StorageFile a in iol)
    {
        myobj.Name = sf.DisplayName.ToString();
        //gw.DisplayMemberPath = "Name";
        var tn = await sf.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView);
        BitmapImage bi = new BitmapImage();
        bi.SetSource(tn);
        myobj.Thumbnail = bi;
        datasource.Add(myobj);
    }
        this.gw.ItemsSource = datasource;
      //  gw.DisplayMemberPath = "data";
        
    
 }