我在转盘上的“koleksibuku”文件夹中有文件夹和文件。我想在moveBtn点击时,它会显示可用文件夹的名称列表(包括根文件夹)。如何在“koleksibuku”文件夹中显示可用文件夹列表?
在gridview上显示文件和文件夹的代码:
loading.IsIndeterminate = true;
StorageFolder koleksibuku = await installedLocation.CreateFolderAsync("koleksibuku", CreationCollisionOption.OpenIfExists);
ObservableCollection<Book> datasource = new ObservableCollection<Book>();
IReadOnlyList<StorageFile> files = await koleksibuku.GetFilesAsync();
IReadOnlyList<StorageFolder> folders = await koleksibuku.GetFoldersAsync();
StorageFolder thumbfolder = await installedLocation.CreateFolderAsync("thumb", CreationCollisionOption.OpenIfExists);
files = await koleksibuku.GetFilesAsync();
folders = await koleksibuku.GetFoldersAsync();
foreach (StorageFile file in files)
{
Book buku = new Book();
buku.Name = file.DisplayName.ToString();
if ((isbukudownloading(file.Name.ToString())) && (file.Name.ToString() != DownloadFileName))
{
}
else
{
StorageFile thumbFile;
StorageFolder thumbFolder;
bool bukuada = true;
try
{
var folder1 = await installedLocation.GetFolderAsync("kolesibuku");
thumbFile = await thumbfolder.GetFileAsync(file.Name.ToString() + ".png");
BitmapImage bi = new BitmapImage();
bi.SetSource(await thumbFile.OpenAsync(FileAccessMode.Read));
buku.Image = bi;
datasource.Add(buku);
}
catch
{
bukuada = false;
}
if (!bukuada)
{
loading.IsIndeterminate = true;
var task = Task.Run(async () => { await RenderCoverBuku(file.Name.ToString(), 0); });
task.Wait();
thumbFile = await thumbfolder.GetFileAsync(file.Name.ToString() + ".png");
BitmapImage bi = new BitmapImage();
bi.SetSource(await thumbFile.OpenAsync(FileAccessMode.Read));
buku.Image = bi;
datasource.Add(buku);
}
}
}
foreach (StorageFolder folder in folders)
{
Book buku = new Book();
buku.Name = folder.DisplayName.ToString();
BitmapImage folderImage = new BitmapImage(new Uri("ms-appx:///images/folders_png8761.png"));
buku.Image = folderImage;
datasource.Add(buku);
}
this.carousel.ItemsSource = datasource;
this.carousel.SelectedItem = carousel.Items[0];
loading.IsIndeterminate = false;
}
private void moveBtn_Click(object sender, RoutedEventArgs e)
{
}
注意: