Hi,

I am writing a function to unzip a zipped file. But I'm getting this error, "Cast from string "C:\temp\FileName.zip" to type 'Integer' is not valid." Below is my coding, I got this error in the bold line. May I know what does the casting error mean here? Why do I need to cast the string of my zip file path to integer?

ExtractZIPfiles(Directory.GetFiles(strFullDirectoryPath, "*.Zip"))


Private Sub ExtractZIPfiles(ByVal pathList() As String)
        Dim x As New ICSharpCode.SharpZipLib.Zip.FastZip
        Dim strFullDirectoryPath As String = Path.GetFullPath("C:\temp")

        For Each s As String In pathList

           [B] x.ExtractZip(pathList(s), strFullDirectoryPath, "csv;xsl")[/B]

        Next
End Sub

Recommended Answers

All 9 Replies

Private Sub ExtractZIPfiles(ByVal pathList() As String)
Dim x As New ICSharpCode.SharpZipLib.Zip.FastZip
Dim strFullDirectoryPath As String = Path.GetFullPath("C:\temp")

For Each s As String In pathList

x.ExtractZip(pathList(s), strFullDirectoryPath, "csv;xsl")

Next
End Sub
hi,
above function's return type may be an integer so u need to declare one variable as integer and rewrite it again as like follows
dim y as int
y=x.ExtractZip(pathList(s), strFullDirectoryPath, "csv;xsl")
it will be execute properly

Private Sub ExtractZIPfiles(ByVal pathList() As String)
Dim x As New ICSharpCode.SharpZipLib.Zip.FastZip
Dim strFullDirectoryPath As String = Path.GetFullPath("C:\temp")

For Each s As String In pathList

x.ExtractZip(pathList(s), strFullDirectoryPath, "csv;xsl")

Next
End Sub
hi,
above function's return type may be an integer so u need to declare one variable as integer and rewrite it again as like follows
dim y as int
y=x.ExtractZip(pathList(s), strFullDirectoryPath, "csv;xsl")
it will be execute properly

Hi,

I've tried your suggestion, it cannot work, because it says the expression

[B]x.ExtractZip(pathList(s), strFullDirectoryPath, "csv;xsl")
[/B]

does not return a value. :(

So anymore suggestion?

Hi all,

My problem been solved. Thanks for reading anyway. ;)

So what did you do to solve it?

The problem came from the string array actually. :)

This pathList(s) is evaluated before the ExtractZip method, pathList is an array and requires an integer argument in the parenthesis representing the index number, but string s is being passed instead.

This pathList(s) is evaluated before the ExtractZip method, pathList is an array and requires an integer argument in the parenthesis representing the index number, but string s is being passed instead.

oh yeah now i get it. Thanks :)

wonder_gal,

as you're new just to let you know, we like to explain solutions as much as possible so that other visitors with similar problems can learn from existing threads instead of starting new ones. Also as you are the owner of this thread you can mark it as solved there is an option on the screen that only you will see, that's also helpful for us to know so we don't waste time reading solved threads.

Thanks for your contribution.

wonder_gal,

as you're new just to let you know, we like to explain solutions as much as possible so that other visitors with similar problems can learn from existing threads instead of starting new ones. Also as you are the owner of this thread you can mark it as solved there is an option on the screen that only you will see, that's also helpful for us to know so we don't waste time reading solved threads.

Thanks for your contribution.

Icic, I got it. I just marked this post as SOLVED already.
Thanks to everyone here for sharing. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.