12 Answers, 1 is accepted
0
Hi Marcel,
Petar Mladenov
the Telerik team
Could you please check out this help article demonstrating how to get started with RadZipLibrary? Please let us know if you need further assistance. We would be glad to help you.
Best wishes,Petar Mladenov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Lee
Top achievements
Rank 1
answered on 17 Nov 2011, 03:10 PM
I'm having a similar issue with extracting files from a zip archive, and the documentation you reference is not helping.
Can you provide a sample project that actually extracts the files from the zip archive and writes them to disk?
Can you provide a sample project that actually extracts the files from the zip archive and writes them to disk?
0

Silvan
Top achievements
Rank 1
answered on 18 Nov 2011, 05:30 PM
Hi
After a lot of trying i create the following sample how to UnZip a file:
My tip: if you like it easier, use the free DotNetZip Library which provide a lot (more) easy-to-use functions.
After a lot of trying i create the following sample how to UnZip a file:
Private
Sub
UnZIP()
'UnZip
Using zipPackage
As
Telerik.Windows.Zip.ZipPackage = zipPackage.OpenFile(
"C:\temp\xyz.zip"
, IO.FileAccess.Read)
If
Not
zipPackage.ZipPackageEntries.Count = 0
Then
Dim
zipEntry
As
ZipPackageEntry = zipPackage.ZipPackageEntries(0)
'Create ZIP-stream
Dim
zipInp
As
ZipInputStream =
New
ZipInputStream(zipEntry.OpenInputStream)
'Create file-stream
Dim
fileStream
As
New
FileStream(
"c:\temp\xyz.txt"
, FileMode.Create, FileAccess.Write)
'Write source-stream nach target-stream
ReadWriteStream(zipInp.BaseStream, fileStream)
End
If
End
Using
End
Sub
Private
Sub
ReadWriteStream(stmRead
As
Stream, stmWrite
As
Stream)
Dim
Length
As
Integer
= 1024
Dim
buffer
As
[
Byte
]() =
New
[
Byte
](Length - 1) {}
Dim
bytesRead
As
Integer
= stmRead.Read(buffer, 0, Length)
'write the bytes
While
bytesRead > 0
stmWrite.Write(buffer, 0, bytesRead)
bytesRead = stmRead.Read(buffer, 0, Length)
End
While
stmRead.Close()
stmWrite.Close()
End
Sub
My tip: if you like it easier, use the free DotNetZip Library which provide a lot (more) easy-to-use functions.
0

Lee
Top achievements
Rank 1
answered on 18 Nov 2011, 08:28 PM
Thanks. Turns out I was closer than I thought.
Your help is greatly appreciated.
I'm actually already using the DotNetZip Library, but I thought I would try to use Telerik's zip library since I'm using their controls for everything else. But you're right, DotNetZip is much easier.
Actually, Telerik's isn't that difficult, but the documentation is terribly incomplete.
Your help is greatly appreciated.
I'm actually already using the DotNetZip Library, but I thought I would try to use Telerik's zip library since I'm using their controls for everything else. But you're right, DotNetZip is much easier.
Actually, Telerik's isn't that difficult, but the documentation is terribly incomplete.
0
Hi Lee,
We will be definitely expanding the RadZipLibrary online documentation. An article on how to unzip a file will be included by the end of the month. And I want to thank you for this feedback.
Also, another approach for extracting zipped files with the RadZipLibrary is:
Regards,
Tina Stancheva
the Telerik team
We will be definitely expanding the RadZipLibrary online documentation. An article on how to unzip a file will be included by the end of the month. And I want to thank you for this feedback.
Also, another approach for extracting zipped files with the RadZipLibrary is:
private
void
UnZipFiles(
string
filePath,
string
destinationPath)
{
FileStream fileStream =
new
FileStream(filePath, FileMode.Open);
//extract all files from archieve
using
(ZipPackage package = ZipPackage.Open(fileStream, FileAccess.Read))
{
foreach
(var entry
in
package.ZipPackageEntries)
{
if
(entry.Attributes != FileAttributes.Directory)
{
SaveFile(entry, destinationPath);
}
}
}
}
//Save the unzipped files
private
static
void
SaveFile(ZipPackageEntry entry,
string
destinationPath)
{
Stream stream = entry.OpenInputStream();
var fileName = destinationPath +
"\\"
+ entry.FileNameInZip;
var directoryName = Path.GetDirectoryName(fileName);
if
(directoryName !=
null
)
{
if
(!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}
StreamReader reader =
new
StreamReader(stream);
string
text = reader.ReadToEnd();
File.WriteAllText(fileName, text);
}
}
Regards,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Manuel
Top achievements
Rank 1
answered on 12 Apr 2013, 09:28 PM
Hello,
the example is not working for me.
I used your c# example to unzip the files.
It works fine for text files like XML or CS.
But the DLL files in the zip package are corrupted after unzip.
If I use a regular unzipper, the files are fine.
Do you have any ideas?
the example is not working for me.
I used your c# example to unzip the files.
It works fine for text files like XML or CS.
But the DLL files in the zip package are corrupted after unzip.
If I use a regular unzipper, the files are fine.
Do you have any ideas?
0
Hi Manuel,
Unfortunately, there is a known issue for the RadZipLibrary working with ".dll" files.
It is logged here, where you can track its progress and vote for it.
We are sorry for any inconvenience caused.
Regards,
Vladislav
the Telerik team
Unfortunately, there is a known issue for the RadZipLibrary working with ".dll" files.
It is logged here, where you can track its progress and vote for it.
We are sorry for any inconvenience caused.
Regards,
Vladislav
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0

Henry
Top achievements
Rank 1
answered on 15 Jan 2014, 06:57 PM
I guess, it does not work with any binary file. I tried Excel and Word files. I think the reason is that the Stream has compressed data and your code has no processing to convert this compressed data into expected format based on file extension. Everything is treated as text.
string text = reader.ReadToEnd();
StreamReader reader = new StreamReader(stream);
string text = reader.ReadToEnd();
File.WriteAllText(fileName, text);
0
Hello Henry,
You can create a ZIP files and include word/excel and other files as long as you include the files with their name and extensions. For instance if you want to add a new Excel file to a zip, you need to add the files like follows: filename+extension("SampleFile.xlsx"). I have attached a sample project demonstrating the approach. Doing so the file will be added to the zip and will be compressed/decompressed as expected.
I hope this information helps.
Kind regards,
Kiril Vandov
Telerik
You can create a ZIP files and include word/excel and other files as long as you include the files with their name and extensions. For instance if you want to add a new Excel file to a zip, you need to add the files like follows: filename+extension("SampleFile.xlsx"). I have attached a sample project demonstrating the approach. Doing so the file will be added to the zip and will be compressed/decompressed as expected.
I hope this information helps.
Kind regards,
Kiril Vandov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Henry
Top achievements
Rank 1
answered on 23 Jan 2014, 01:59 PM
Kiril,
your example shows how to zip files. I've never had the problem with that. But UNZIPPING does not work. Please could you try to UNZIP your zip file using Telerik library and you will see that all files from output will be corrupted unless they are text files (.txt, .sql etc).
At least I tried with .pdf, .xls, .doc etc.
Thanks,
Henry
your example shows how to zip files. I've never had the problem with that. But UNZIPPING does not work. Please could you try to UNZIP your zip file using Telerik library and you will see that all files from output will be corrupted unless they are text files (.txt, .sql etc).
At least I tried with .pdf, .xls, .doc etc.
Thanks,
Henry
0
Hello Henry,
Please excuse me if I have misunderstood your initial question.
In order to unzip a zip file using the ZipLibrary, you need to do the following steps:
1) Open the Zip file:
2) Traverse through all its items in the zipFile.ZipPackageEntries collection.
3) Open the decompressed stream of each entry
4) Create new byte[] to contain the zipped data. Please note that this array should be with the size of the UncompressedFile size.
5) Read the bytes from the decompressed stream
6) Access the filename and its extension in the zipEntry.FileNameInZip property
7) Create a new file for each entry
I have attached a sample project demonstrating the approach. Run the attached project press the "Create ZIP file" button, then press the "Extract" button to extract the zipped files.
I hope this information helps.
Kind regards,
Kiril Vandov
Telerik
Please excuse me if I have misunderstood your initial question.
In order to unzip a zip file using the ZipLibrary, you need to do the following steps:
1) Open the Zip file:
using (ZipPackage zipFile = ZipPackage.OpenFile(zipFilePath, FileAccess.Read))
foreach (var zipEntry in zipFile.ZipPackageEntries)
Stream strm = zipEntry.OpenInputStream();
byte[] Bytes = new byte[zipEntry.UncompressedSize];
strm.Read(Bytes, 0, (int)zipEntry.UncompressedSize);
7) Create a new file for each entry
string extractedFilePath = path + @"\New" + fileName;
using (FileStream fs = new FileStream(extractedFilePath, FileMode.Create))
{
fs.Write(Bytes, 0, Bytes.Length);
fs.Close();
}
I have attached a sample project demonstrating the approach. Run the attached project press the "Create ZIP file" button, then press the "Extract" button to extract the zipped files.
I hope this information helps.
Kind regards,
Kiril Vandov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Henry
Top achievements
Rank 1
answered on 28 Jan 2014, 05:53 PM
Hi Kiril,
Thank you very much! Your code works in the way it was expected to.
Thank you very much! Your code works in the way it was expected to.