Error : end of central directory record could not be found during unzipping . RRS feed

  • Question

  • Hi

    I am coping a encrypted file(.enc) from USB to package's tempFolder 

      await Task.Run(() =>
      System.IO.File.Copy(encryptSourceFile.Path, $"{tempFolder.Path}\\{PDSConstants.PDSFILE_NAME}");

    then Decrypting-

     bool isDecrypted = await EncryptionDecryptionHelper.DecryptUSBFile(PDSConstants.PDSFILE_NAME, tempFolder, DecryptionPassword);

    then Unzipping-

     ZipFile.ExtractToDirectory($"{tempFolder.Path}\\{"de_"}{PDSConstants.PDSFILE_NAME}", folder.Path);

    Decryption code is-

     public static async Task<bool> DecryptUSBFile(string fileName, StorageFolder folder, string decryptionPassword)
                    string postfix = "de_";
                    StorageFile deLargefile = await folder.CreateFileAsync($"{postfix}{fileName}", CreationCollisionOption.ReplaceExisting);

                    using (Stream input = new FileStream($"{folder.Path}\\{fileName}", FileMode.OpenOrCreate))
                        using (Stream output = new FileStream(deLargefile.Path, FileMode.OpenOrCreate))
                            output.Position = 0;
                            byte[] buffer = new byte[1024 * 1024];
                            ICryptoTransform decryptor = GetCryptoTransform(false,decryptionPassword);
                            while (await input.ReadAsync(buffer, 0, buffer.Length) > 0)
                                var data = await AESDecryptToStorage(buffer, decryptor);
                                await output.WriteAsync(data, 0, data.Length);

                    return true;
                catch (Exception ex)

                return false;

    I am getting error "end of central directory record could not be found during unzipping"

    sandeep chauhan

    Tuesday, September 17, 2019 2:10 PM

All replies

  • Hi,

    The problem is Unzip can't find the line of code that signals the end of the archive.

    This error occurs, indicating that your compressed file may not be in .zip format or the compressed file is corrupt.

    You can try to test your code with a zip archive or fix a damaged package.

    Best regards.

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 18, 2019 2:12 AM