This is a migrated thread and some comments may be shown as answers.

Error when extracting zip files

12 Answers 665 Views
ZipLibrary
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 09 Mar 2017, 12:29 AM

Hi Guys.

Im using the following to extract files to a new directory under windows 10.

Users do not have Admin rights

 

Dim NewDir As String = GetGUID

            System.IO.Directory.CreateDirectory(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir))
            If System.IO.Directory.Exists(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir)) Then
                Try
                    Telerik.WinControls.Zip.Extensions.ZipFile.ExtractToDirectory(ZipFile, My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir))
                    For Each f As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir))
                        ImportCollection.Add(f)
                    Next
                Catch ex As Exception
                    MessageBox.Show(ex.ToString)
                End Try

                For Each f As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir))
                    ImportCollection.Add(f)
                Next
            End If

 

Unfortunately the zip extract method always fails with an "Access denied" error message.

However the "for loop" which is designed to add the files extracted to a string collection has no problem reading any files in the directory

 

Is the some sort of write permission setting im missing in the Telerik.WinControls.Zip.Extensions.ZipFile.ExtractToDirectory method

12 Answers, 1 is accepted

Sort by
0
Andre
Top achievements
Rank 1
answered on 09 Mar 2017, 12:34 AM

Should mention 

VB 2015 Latest release of Telerik win forms,  Framework target is 4.6.1 and app is 64 bit, win 10 64

0
Martin Ivanov
Telerik team
answered on 13 Mar 2017, 03:05 PM
Hello Andre,

There is no permission setting in the zip library. In order to extract the zip you will need to make sure that you have an access to the file. Otherwise, you won't be able to get its content.

Regards,
Martin
Telerik by Progress

0
Andre
Top achievements
Rank 1
answered on 13 Mar 2017, 07:37 PM

well ... to quote...we have a problem Huston ;-)

I have tried the following and get no errors with the zip file copy or delete however the zip library function ALWAYS fails with a  " file  access error"

 Dim NewDir As String = GetGUID
            Dim TestFile As String = GetGUID

            System.IO.Directory.CreateDirectory(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir))
            If System.IO.Directory.Exists(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir)) Then
                Try
                    System.IO.File.Copy(ZipFile, My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir & "\" & TestFile & ".zip"))

                    System.IO.File.Delete(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir & "\" & TestFile & ".zip"))
                Catch ex As Exception
                    MessageBox.Show("Could not access temp directory")
                    Exit Function
                End Try

                Try
                    Telerik.WinControls.Zip.Extensions.ZipFile.ExtractToDirectory(ZipFile, My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir), System.Text.Encoding.UTF8)

                    For Each f As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CombinePath(VADataCacheClass.VaTempStorage, NewDir))
                        ImportCollection.Add(f)
                    Next
                Catch ex As Exception
                    MessageBox.Show(ex.ToString)
                End Try
End If

0
Andre
Top achievements
Rank 1
answered on 13 Mar 2017, 10:55 PM

I though id try something else and the following returns "Specified method is not supported" at

 Telerik.WinControls.Zip.Extensions.ZipFile.ExtractToFile(e, f)

Perhaps you could let me know whats going on....

 Try

                    Using stream As Stream = File.OpenRead(ZipFile)
                        Using zip As New ZipArchive(stream, ZipArchiveMode.Read, False, Nothing)
                            For Each e As ZipArchiveEntry In zip.Entries
                                Dim f As String = My.Computer.FileSystem.CombinePath(NewDir, e.Name)
                                Telerik.WinControls.Zip.Extensions.ZipFile.ExtractToFile(e, f)
                            Next
                        End Using
                    End Using




                    For Each f As String In My.Computer.FileSystem.GetFiles(NewDir)
                        ImportCollection.Add(f)
                    Next

                Catch ex As Exception
                    MessageBox.Show(ex.ToString)
                End Try

0
Martin Ivanov
Telerik team
answered on 16 Mar 2017, 06:37 PM
Hello Andre,

I missed the fact that you are using WinForms. Excuse me for this. The ZipExtensions are not supported in UI for WinForms. This is why the ZipFile methods doesn't work in your project. You can check the supported frameworks in the "Available for:" label at the top of each document processing help article . 

Regards,
Martin
Telerik by Progress

0
Andre
Top achievements
Rank 1
answered on 16 Mar 2017, 07:46 PM

Good Morning,

Its disappointing that I have been forced to wait over 12 days for a resolution to this and then find that the mistake was at your end despite me being clear it was a winform app

Perhaps you would be good enough to detail how I would actually extract the files to a folder.

The following coded is not clear on how this should be done.

"Display" is about all I can do...there does not appear to be a mechanism for extracting the files , or that i can find, in the somewhat brief help files.

Using stream As Stream = File.Open("test.zip", FileMode.Open)Using archive As New ZipArchive(stream)

' Display the list of the files in the selected zip file using the ZipArchive.Entries property.

End Using

End Using

0
Martin Ivanov
Telerik team
answered on 20 Mar 2017, 02:26 PM
Hello Andre,

I prepared a small example where you can find implementations of ExtractToDirectory()  and ExtractToFile() methods. Please give it a try and let me know if it helps.

About, the waiting, indeed, I mislead you with the provided information. Please accept my sincere apologies. 

As a side note, regarding the forums, we do our best to help our community. However, we do not guarantee a fast reply here. This is why if you need further assistance that should be handled in a shorter time frame I would recommend you to open a new support ticket from your telerik.com account.

Regards,
Martin
Telerik by Progress

0
Andre
Top achievements
Rank 1
answered on 20 Mar 2017, 08:10 PM

Thank you for your reply and sample code.

In my experience with working with other tool providers a delay in response to a simple question is usually handled more promptly.

I would also mention that whist Telerik documentation suggest that extension methods are not supported in a win form app the actual sample project (eg: zip library) for win forms  do use extension methods. 

This has contributed to my frustration

0
Martin Ivanov
Telerik team
answered on 23 Mar 2017, 01:58 PM
Hello Andre,

I hope the provided project helps you to achieve your goal.

As for the WinForms sample project you mentioned, can you point me to the specific example, so I can check it and see what happens?

Regards,
Martin
Telerik by Progress

0
Andre
Top achievements
Rank 1
answered on 23 Mar 2017, 08:46 PM

Hello mark

I was unaware as to the expected response times on the forums as apposed to a direct request to support.

As a result I offered feedback to Telerik on my experiences with this case.

Part of that feed back included screen shots of the win forms example which demonstrates the use of extension methods and further advice about your Australasian contact who no longer working for your company but your web sites continue to list him as a go to person.

Thank you for your help , The sample project you provided works as expected

Andre

0
Martin Ivanov
Telerik team
answered on 28 Mar 2017, 04:08 PM
Hello Andre,

It's great to hear that the example helped. And also it's good that you shared your feedback, even if it wasn't related to a nice experience. 

I dug a bit deeper into the zip extensions for WinForms and it seems that the suite exposes its own implementation of the Zip extensions (found in the Telerik.WinControls.Zip.Extensions namespace) which actually is the same as the one in the Telerik.Windows.Zip.Extensions assembly. We are going to update our documentation according to this. So, you can use the zip extensions from the WinControls dll. I updated your Telerik points as a small gesture of gratitude for reporting this to us.

We also further tested your case and reproduced the "Access denied" error in a scenario where the ZipFile.ExtractToFile() method is used along with the archive entry's Name property which is empty. The Name is empty when the entry is a folder. In this case the error is observed. To resolve this you will need to make sure that the "destinationFileName" parameter of the method points to a non-empty string.

We can also reproduce the "Access denied" exception in some cases where the ExtractToDirectory() is used. However, we will need some additional time to check why this happens. I am gonna get back to you a bit later with more information on this. 

About the "Specified method is not supported" exception, we couldn't reproduce this. Can you open a new support ticket from your telerik.com account and attach an isolated project that shows the structure of the zip file and the reported exception. This will allow us to test it locally and investigate what happens.

Thank you for any help you can provide. 

Regards,
Martin
Telerik by Progress

0
Martin Ivanov
Telerik team
answered on 31 Mar 2017, 03:23 PM
Hi Andre,

We investigated the reported exceptions. Actually, we've been able to reproduce both access denied and not supported errors. And we can confirm those are bugs in the Zip extensions implementation. We've logged them in the feedback portal where you can track their status.  We updated your Telerik points for helping us finding those issues. 

As a workaround you can use the implementation provided in the project from one of my previous replies.

Once again, I would like to apologize for misleading you with the Zip extensions.

Regards,
Martin
Telerik by Progress

Tags
ZipLibrary
Asked by
Andre
Top achievements
Rank 1
Answers by
Andre
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or