當前位置: 首頁>>代碼示例>>C#>>正文


C# StorageFolder.GetBasicPropertiesAsync方法代碼示例

本文整理匯總了C#中Windows.Storage.StorageFolder.GetBasicPropertiesAsync方法的典型用法代碼示例。如果您正苦於以下問題:C# StorageFolder.GetBasicPropertiesAsync方法的具體用法?C# StorageFolder.GetBasicPropertiesAsync怎麽用?C# StorageFolder.GetBasicPropertiesAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Windows.Storage.StorageFolder的用法示例。


在下文中一共展示了StorageFolder.GetBasicPropertiesAsync方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateFolder

        async Task UpdateFolder(StorageFolder storageFolder)
        {
            var folder = await databaseConnection.Table<Folder>().Where(p => p.Path == storageFolder.Path).FirstOrDefaultAsync();

            if (folder == null)
            {
                folder = new Folder() { LastUpdateTime = DateTime.Now, CheckedToday = true, Path = storageFolder.Path };
                await databaseConnection.InsertAsync(folder);

                await UpdateFilesInFolder(folder.Id, storageFolder);
            }
            else
            {
                var dateChanged = (await storageFolder.GetBasicPropertiesAsync()).DateModified;
                if (dateChanged > folder.LastUpdateTime)
                {
                    await UpdateFilesInFolder(folder.Id, storageFolder);
                    folder.LastUpdateTime = DateTime.Now;
                }

                folder.CheckedToday = true;
                await databaseConnection.UpdateAsync(folder);
            }

            foreach (var subFolder in await storageFolder.GetFoldersAsync())
                await UpdateFolder(subFolder);
        }
開發者ID:JulianMH,項目名稱:music-3,代碼行數:27,代碼來源:LocalLibrarySource.cs

示例2: UpdateFilesInFolder

        private async Task UpdateFilesInFolder(int folderId, StorageFolder storageFolder)
        {
            var files = await databaseConnection.Table<File>().Where(p => p.FolderId == folderId).ToListAsync();

            foreach (var storageFile in await storageFolder.GetFilesAsync())
            {
                var file = files.Where(p => p.Path == storageFile.Path).FirstOrDefault();

                if (file == null)
                {
                    await databaseConnection.InsertAsync(new File() { LastUpdateTime = DateTime.Now, FolderId = folderId, Path = storageFile.Path });

                    await AddSong(storageFile);
                }
                else
                {
                    files.Remove(file);

                    var dateChanged = (await storageFolder.GetBasicPropertiesAsync()).DateModified;
                    if (dateChanged > file.LastUpdateTime)
                    {
                        await RemoveSong(storageFile.Path);
                        await AddSong(storageFile);

                        file.LastUpdateTime = DateTime.Now;
                        await databaseConnection.UpdateAsync(file);
                    }

                }
            }
        }
開發者ID:JulianMH,項目名稱:music-3,代碼行數:31,代碼來源:LocalLibrarySource.cs


注:本文中的Windows.Storage.StorageFolder.GetBasicPropertiesAsync方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。