[WP8.1] [c#] [xaml]从SD卡获取文件&通过选择器进行内部存储 [英] [WP8.1][c#][xaml] getting files from SD card & internal storage through picker

查看:77
本文介绍了[WP8.1] [c#] [xaml]从SD卡获取文件&通过选择器进行内部存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码UWP版本没有任何问题,但在Windows Phone 8.1中显示为obselete,如何在选择SD卡或文件夹时获取所有文件,我在UWP中使用的代码应用程序低于

i am using below code UWP version with out any issues but in windows phone 8.1 it is showing as obselete, how can i get all files when SD card or a folder is selected, the code i am using in UWP apps is below

internal static async void GetFilesResult(string ftype)
{
            FolderPicker folderpicker = new FolderPicker();
            folderpicker.FileTypeFilter.Add("*");

            StorageFolder tmpfolder = await folderpicker.PickSingleFolderAsync();


QueryOptions options;

if (ftype == "Aud")
            {
                options = new QueryOptions(CommonFileQuery.DefaultQuery, new[] { ".mp3" });
                options.FolderDepth = FolderDepth.Deep;
                StorageFileQueryResult k = tmpfolder.CreateFileQueryWithOptions(options);

                var files = await k.GetFilesAsync();
            }
}

推荐答案

Hello kranthi88,

Hello kranthi88,

在Windows Phone 8.1中,此方法未实现。您应该使用
PickFolderAndContinue()
方法。可以在PickFolderAndContinue回调方法上检索该文件夹。

In windows phone 8.1, this method isn’t implemented. You should use PickFolderAndContinue() method. The folder could be retrieved on PickFolderAndContinue callback method.

public void ContinueFolderPicker(FolderPickerContinuationEventArgs args)
        {
            StorageFolder folder = args.Folder;
            if (folder != null)
            {
                // Application now has read/write access to all contents in the picked folder (including other sub-folder contents)
                StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
                OutputTextBlock.Text = "Picked folder: " + folder.Name;
            }
            else
            {
                OutputTextBlock.Text = "Operation cancelled.";
            }
        }


 

您可以从以下网址查看更多详细信息:  文件选择器示例

最好的问候,

Xavier Eoro

Xavier Eoro


这篇关于[WP8.1] [c#] [xaml]从SD卡获取文件&通过选择器进行内部存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆