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

前端之家收集整理的这篇文章主要介绍了c# – 获取文件夹文件的速度比StorageFolder.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

原文链接:https://www.f2er.com/csharp/99796.html

猜你在找的C#相关文章