/// <summary> /// Returns a list of all filenames in the remote .zip archive /// </summary> /// <param name="archiveUrl">URL of the .zip archive</param> /// <returns>List of filenames</returns> public static async Task <IEnumerable <string> > GetFileList(string archiveUrl) { PartialZipDownloader downloader = new PartialZipDownloader(archiveUrl); PartialZipInfo info = await downloader.Open(); return(info.CentralDirectory.Select(cd => cd.FileName).OrderBy(f => f)); }
/// <summary> /// Downloads a specific file from a remote .zip archive /// </summary> /// <param name="archiveUrl">URL of the .zip archive</param> /// <param name="filePath">Path of the file</param> /// <returns>File content</returns> public static async Task <byte[]> DownloadFile(string archiveUrl, string filePath) { PartialZipDownloader downloader = new PartialZipDownloader(archiveUrl); PartialZipInfo info = await downloader.Open(); byte[] content = await downloader.Download(info, filePath); return(content); }
/// <summary> /// Downloads a specific file from a remote .zip archive /// </summary> /// <param name="archiveUrl">URL of the .zip archive</param> /// <param name="filePath">Path of the file in archive</param> /// <param name="writePath">Path where the file will be written</param> /// <param name="preserveTime">Preserve modification date</param> /// <returns>File content</returns> public static async Task DownloadFile(string archiveUrl, string filePath, string writePath) { PartialZipDownloader downloader = new PartialZipDownloader(archiveUrl); PartialZipInfo info = await downloader.Open(); var content = await downloader.Download(info, filePath); File.WriteAllBytes(writePath, content.Item1); File.SetLastWriteTimeUtc(writePath, content.Item2); }