在vb中解压缩文件

时间:2015-02-15 04:57:10

标签: vb.net unzip shell32

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

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

  

附加信息:未将对象引用设置为对象的实例。

    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),但返回相同的错误。

(148是拉链内的物品数量)

1 个答案:

答案 0 :(得分:0)

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