public static async Task DeleteDirectoryIfExists(this IStorageServiceHandler storageService, string path)
 {
     if (await storageService.DirectoryExistsAsync(path))
     {
         await storageService.DeleteDirectoryAsync(path);
     }
 }
 public static async Task CreateDirectoryIfNotThere(this IStorageServiceHandler storageService, string path)
 {
     if (!await storageService.DirectoryExistsAsync(path))
     {
         await storageService.CreateDirectoryAsync(path);
     }
 }
Exemple #3
0
        public async Task <List <DeviceFileInfo> > GetFileSystemEntries(string path)
        {
            var list = new List <DeviceFileInfo>();

            try
            {
                path = AnyTimePath(path);

                if (await _storageService.DirectoryExistsAsync(path))
                {
                    var folder = await _storageService.RootFolder().GetFolderAsync(path);

                    if (folder != null)
                    {
                        var files = await folder.GetFilesAsync();

                        list.AddRange(files.Select(f => new DeviceFileInfo {
                            Name = f.Name, Path = string.Concat(path, "\\", f.Name)
                        }));
                    }
                }
            }
            catch
            { }
            return(list);
        }
 public static async Task MoveFileIfExists(this IStorageServiceHandler storageService, string source, string destination, bool overwrite)
 {
     if (await storageService.FileExistsAsync(source))
     {
         var destinationFolder = Path.GetDirectoryName(destination);
         if (!await storageService.DirectoryExistsAsync(destinationFolder))
         {
             await storageService.CreateDirectoryAsync(destinationFolder);
         }
         await storageService.MoveFileAsync(source, destination, overwrite);
     }
 }