public static async Task <LocalCacheManager> InitializeAsync(StorageFolderType secondaryFolderType, string currentFolderName = "") { var manager = new LocalCacheManager(); manager.RootFolder = StorageHelper.LocalCacheFolder; manager.SecondaryFolderType = secondaryFolderType; manager.SecondaryFolder = await manager.GetOrCreateSecondaryFolderAsync() /*.ConfigureAwait(false)*/; manager.CurrentFolder = await manager.GetOrCreateCurrentFolderAsync(currentFolderName) /*.ConfigureAwait(false)*/; return(manager); }
public static async Task <string> GetFullMappedPathAsync(string url, StorageFolderType folderType, string fileName = "", string subType = "") { var storageManager = await LocalCacheManager.InitializeAsync(folderType); var dir = storageManager.CurrentFolder?.Path; if (string.IsNullOrEmpty(fileName)) { fileName = GetDownloadedLocalFileName(url, subType); } return(System.IO.Path.Combine(dir, fileName)); }
protected SecureFileStorage(StorageFolderType folderType, string filename, DataProtectionType protectionType) { this.folder = GetFolder(folderType); this.filename = filename; if (protectionType == DataProtectionType.User) { this.protectionDescriptor = "LOCAL=user"; } else { this.protectionDescriptor = "LOCAL=machine"; } }
protected async Task <List <StorageFile> > PullFilesFromFolderAsync(StorageFolderType <StorageFolder> listItem) { List <StorageFile> storageFileList = new List <StorageFile>(); IReadOnlyList <StorageFile> fileList = await listItem.Folder.GetFilesAsync(); foreach (StorageFile storageFile in fileList) { storageFileList.Add(storageFile); } GC.Collect(2); return(storageFileList); }
private static StorageFolder GetFolder(StorageFolderType folderType) { try { switch (folderType) { case StorageFolderType.Local: return(ApplicationData.Current.LocalFolder); case StorageFolderType.Roaming: return(ApplicationData.Current.RoamingFolder); case StorageFolderType.Temporary: return(ApplicationData.Current.TemporaryFolder); } } catch (InvalidOperationException) { Debug.WriteLine("Physical storage not available"); } return(null); }
public static async Task <bool> ClearAsync(StorageFolderType secondaryFolderType) { var manager = await InitializeAsync(secondaryFolderType); return(await manager.ClearAsync()); }