Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Problem z UnZipem pliku?


Rekomendowane odpowiedzi

Opublikowano

Wziąłem kod: (dodałem odwołanie Microsoft Shell...)

Dim UnZipFile As String = "C:\moje dane\Nowy.rar"
        Dim UnZipFolder As String = "c\moje dane\Test"
        Dim sc As New Shell32.Shell()
        IO.Directory.CreateDirectory(UnZipFolder)
        Dim output As Shell32.Folder = sc.NameSpace(UnZipFolder)
        Dim input As Shell32.Folder = sc.NameSpace(UnZipFile)
        output.CopyHere(Input.Items, 4)

i wywala błąd:

 

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in UnZip file.exe
Additional information: W wyniku wywołania składnika modelu COM został zwrócony błąd HRESULT E_FAIL.

 

w linijce z:

Dim input As Shell32.Folder = sc.NameSpace(UnZipFile)
Opublikowano

Zrobiłem to tak:

Public Class Form1
    Dim outputZip As String = "C:\moje dane\zip\NovaCraft.rar"
    Dim inputFolder As String = "C:\moje dane"


    Dim inputZip As String = "C:\moje dane\NovaCraft.rar"
    Dim outputFolder As String = "C:\moje dane\unzip"


    Dim shObj As Object = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"))


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'Dim UnZipFile As String = "C:\moje dane\NovaCraft.rar"
        'Dim UnZipFolder As String = "c\moje dane\Test"
        'Dim sc As New Shell32.Shell()
        'IO.Directory.CreateDirectory(UnZipFolder)
        'Dim output As Shell32.Folder = sc.NameSpace(UnZipFolder)
        'Dim input As Shell32.Folder = sc.NameSpace(UnZipFile)
        'output.CopyHere(input.Items, 4)
        UnZip()
    End Sub


    Sub Zip()
        Dim startBytes() As Byte = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, _
                                     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
        FileIO.FileSystem.WriteAllBytes(outputZip, startBytes, False)
        Dim input As Object = shObj.NameSpace((inputFolder))
        Dim output As Object = shObj.NameSpace((outputZip))
        output.CopyHere((input.Items), 4)
    End Sub


    Sub UnZip()
        IO.Directory.CreateDirectory(outputFolder)
        Dim output As Object = shObj.NameSpace((outputFolder))
        Dim input As Object = shObj.NameSpace((inputZip))
        output.CopyHere((input.Items), 4)
    End Sub
End Class

Tylko że nadal występuje błąd w części z :

Dim input As Object = shObj.NameSpace((inputZip))

Oraz błąd:

 

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll
Additional information: Nieokreślony błąd. (Wyjątek od HRESULT: 0x80004005 (E_FAIL))

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...