解压缩 vb 中的文件

Unzipping A file in vb

我尝试解压缩文件时出现异常

当我删除我收到的尝试时:

Additional information: Object reference not set to an instance of an object.

    Try
        Dim sc As New Shell32.Shell()
        '
        'Create directory in which you will unzip your files .
        '
        IO.Directory.CreateDirectory(Application.StartupPath & "/Packs/SkyNet/mods")
        '
        'Declare the folder where the files will be extracted
        '
        Dim output As Shell32.Folder = sc.NameSpace(Application.StartupPath & "/Packs/SkyNet/mods")
        '
        'Declare your input zip file as folder  .
        '
        Dim input As Shell32.Folder = sc.NameSpace(Application.StartupPath & "/Downloads/SkyNet.zip")
        '
        'Extract the files from the zip file using the CopyHere command .
        '
        output.CopyHere(input.Items, 4)
        My.Computer.FileSystem.WriteAllText(Application.StartupPath & "/Config/SkyNet.pack", "SkyNet Installed", False)
    Catch ex As Exception
        MessageBox.Show("Could Not Extract Pack: SkyNet", "SkyNet Launcher: Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        My.Computer.FileSystem.WriteAllText(Application.StartupPath & "/Config/SkyNet.pack", "SkyNet Not Installed", False)
    End Try

我试过将 output.CopyHere(input.Items, 4) 设置为 output.CopyHere(input.Items , 148) 但 returns 同样的错误。

(148 是 zip 内的项目数)

如果输入或输出文件夹的路径无效,则会导致此错误。在 dim 语句中使用它们之前检查您的路径。