Get File Entries and names from ZIP stored on Azure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Azure.Storage; | |
using Azure.Storage.Blobs; | |
using System; | |
using System.IO.Compression; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace GetZipFileNamesFromAzureZip | |
{ | |
class Program | |
{ | |
private const string StorageAccountName = "xxxxxx"; | |
private const string StorageAccountKey = "xxxxxxxxxxxxxxx"; | |
private const string ContainerName = "xxxxxxxxxx"; | |
private const string FileName = "file.zip"; | |
private const string Url = "https://" + StorageAccountName + ".blob.core.windows.net"; | |
static async Task Main(string[] args) | |
{ | |
BlobServiceClient client = new BlobServiceClient(new Uri(Url), new StorageSharedKeyCredential(StorageAccountName, StorageAccountKey)); | |
var container = client.GetBlobContainerClient(ContainerName); | |
var blobClient = container.GetBlobClient(FileName); | |
var stream = await blobClient.OpenReadAsync(); | |
using ZipArchive package = new ZipArchive(stream, ZipArchiveMode.Read); | |
Console.WriteLine(string.Join(",", package.Entries.Select(x => x.FullName).ToArray())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment