加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 获取文件夹文件的速度比StorageFolder.GetFilesAsync()更

发布时间:2020-12-15 07:52:51 所属栏目:百科 来源:网络整理
导读:StorageFolder.GetFilesAsync非常慢: 对于包含~3500个文件的文件夹,大约需要7秒 回到Windows Phone 8.0 Silverlight,我能够更快地获得CameraRoll的内容(通过MediaLibrary): 1秒,相同数量的文件 有没有可能加速GetFilesAsync,或者有没有其他方法来获取文件
StorageFolder.GetFilesAsync非常慢:

对于包含~3500个文件的文件夹,大约需要7秒

回到Windows Phone 8.0 Silverlight,我能够更快地获得CameraRoll的内容(通过MediaLibrary):

>< 1秒,相同数量的文件
有没有可能加速GetFilesAsync,或者有没有其他方法来获取文件夹的文件?

我需要照片文件立即提取地理标记或DateTaken等信息.您可以看到他们在我的应用程序GeoPhoto中加载Silverlight的速度有多快 – 我现在正试图移植到UWP.我已经实现了缓存(使用图片路径映射地理标记和DateTaken),所以我只需要后续应用程序启动的图片路径.然后可以稍后显示尚未缓存的照片(在长GetFilesAsync调用之后),但是在他启动应用程序后立即向用户提供他可以与之交互的内容非常重要.

解决方法

我想知道你是否读过这篇文章: https://www.suchan.cz/2014/07/file-io-best-practices-in-windows-and-phone-apps-part-1-available-apis-and-file-exists-checking/

Windows 8.1 – finally on Windows 8.1 the fastest method is the new StorageFolder.TryGetItemAsync method,but only by a slim margin when
comparing to other methods. The main benefit here is definitely the
simple code required without any Exception catching if the file does
not exists. The results for sync methods are similar to Windows 8
platform,if original synchronization context is not required,the
sync methods are a better choice.

In short,for checking if target file exists,on WP8 and WP8.1 Silverlight the fastest method is File.Exists,on Windows 8 and WP8.1
XAML you should use StorageFolder.GetFileAsync,and on Windows 8.1 use
the new method StorageFolder.TryGetItemAsync. Do NOT use the iteration
of StorageFiles returned from StorageFolder.GetFilesAsync on any
platform,it is terribly slow.
Also if you don’t need co continue on
the original thread,you can use the synchronous alternatives on WP8.1
XAML,Windows 8 and Windows 8.1 platforms.

或类似的东西?

StorageFolder.GetItemsAsync(UInt32,UInt32)

获取第一个X数量的文件,以便为用户提供您想要的即时反馈.之后加载其余的.

https://msdn.microsoft.com/en-us/library/windows/apps/br227287.aspx

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读