This repository was archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
This repository was archived by the owner on Dec 6, 2024. It is now read-only.
BackupWrite Native method return (13) the data is invalid #525
Copy link
Copy link
Open
Description
When use backupFileStream writer to create .zip file and add files inside it using Xceed.Zip.ReaderWriter.ZipWriter the BackupWrite native method return (13) the data is invalid. The code sample below :
private void createZipFile(string _path)
{
try
{
FileInfo info = new FileInfo(_path);
Xceed.Zip.ReaderWriter.ZipItemLocalHeader oZipEntry = null;
string sZipFileGUID = Guid.NewGuid().ToString();
if (!Directory.Exists(info.DirectoryName))
Directory.CreateDirectory(info.DirectoryName);
Alphaleonis.Win32.Filesystem.BackupFileStream backupFileStream = new Alphaleonis.Win32.Filesystem.BackupFileStream(info.DirectoryName + Path.DirectorySeparatorChar + sZipFileGUID + ".zip", System.IO.FileMode.Create, System.Security.AccessControl.FileSystemRights.FullControl);
oZipOutputStream = new Xceed.Zip.ReaderWriter.ZipWriter(backupFileStream);
using (Alphaleonis.Win32.Filesystem.BackupFileStream oReader = new Alphaleonis.Win32.Filesystem.BackupFileStream(_path, System.IO.FileMode.Open, System.Security.AccessControl.FileSystemRights.Read, System.IO.FileShare.Read))
{
Xceed.Zip.ReaderWriter.ZipItemLocalHeader localHeader = new Xceed.Zip.ReaderWriter.ZipItemLocalHeader();
localHeader.CompressionLevel = Xceed.Compression.CompressionLevel.None;
localHeader.CompressionMethod = Xceed.Compression.CompressionMethod.Deflated;
localHeader.FileName = @"\" + info.Name;
localHeader.LastWriteDateTime = DateTime.Now;
oZipOutputStream.WriteItemLocalHeader(localHeader);
byte[] buffer = new byte[65536];
int read = 0;
while (true)
{
if (oZipOutputStream != null)
{
read = oReader.Read(buffer, 0, buffer.Length);
if (read <= 0)
break;
//Here when call WriteItemData the backupFileStream call write method and exception return: (13) the data is invalid.
oZipOutputStream.WriteItemData(buffer, 0, read);
}
}
}
if (oZipOutputStream != null)
{
oZipOutputStream.CloseZipFile();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels