Получить список файлов, содержащихся в zip-файле, из встроенных ресурсов?(Без извлечения архива из ресурсов) - PullRequest
0 голосов
/ 23 февраля 2019

Здравствуйте, я на самом деле ищу как получить список файлов, содержащийся в zip-файле, сохраненном во встроенных ресурсах, без извлечения этого zip-файла из ресурсов .

    static List<String> ZipFileContent()
    {
        List<String> ZipFileContentList = new List<String>();

        using (ZipArchive ClientZipArchive = ZipFile.OpenRead("Application1.Resources.File1.zip")) //Trying to declare the embedded resource path here
        {
            foreach (ZipArchiveEntry ClientZipArchiveEntry in ClientZipArchive.Entries)
            {
                ZipFileContentList.Add(ClientZipArchiveEntry.FullName);
            }

            return ZipFileContentList;
        }
    }

Другая идея: использовать Stream для получения буфера zip-файлов из ресурсов и, наконец, получить список содержимого этого zip-файла:

    static byte[] GetBuffer(string ResourcePath)
    {
        Assembly TargetAssembly = Assembly.GetExecutingAssembly();

        using (Stream ClientStream = TargetAssembly.GetManifestResourceStream(TargetAssembly.GetName().Name + "." + ResourcePath))
        {
            if (ClientStream != null)
            {
                byte[] Buffer = new byte[ClientStream.Length];

                return Buffer;
            }
            else
            {
                return null;
            }
        }
    }

    static void InterpretBuffer()
    {
        byte[] ZipFileBuffer = GetBuffer("Resources.File1.zip");

        //Do something with ZipFileBuffer to know the list of file contained in the zip file
    }

Спасибо заранее

...