#1 28. April 2009 VB .NET 2008 entpacken per Command Line Hi Leute Ich schreibe gerade an einem kleinen Programm das im Hintergrund RAR-Dateien entpacken soll. Was ich nur seltsam finde ist folgendes: Wenn die Datei mit Winrar gepackt wurde funktioniert alles reibungslos. Wurde sie aber mit WinZip gepackt, so arbeitet er zwar, aber es wird nichts entpackt. Öffne ich die Datei ganz normal mit WinRAR so zeigt er mir alle Dateien an. Ich frage mich halt, wie es sein kann dass ich mit WinRAR selbst solche Dateien öffnen kann, per Command Line jedoch nicht. Hier mal der entsprechende Ausschnitt aus meinem QUellcode: Code: Dim p As New Process() Dim cbrPath As String = Chr(34) + Filename + Chr(34) p.StartInfo.FileName = RarPath p.StartInfo.Arguments = "e " + cbrPath + " c:\test\temp\" p.StartInfo.UseShellExecute = False p.StartInfo.RedirectStandardOutput = True p.StartInfo.CreateNoWindow = True Dim sOutput As String p.Start() sOutput = p.StandardOutput.ReadToEnd() p.WaitForExit() p.Close() If Not sPath.EndsWith("\") Then sPath = sPath & "\" Dim oDir As New System.IO.DirectoryInfo(sPath) Dim oFiles As System.IO.FileInfo() = oDir.GetFiles() Dim oFile As System.IO.FileInfo For Each oFile In oFiles If oFile.Name.EndsWith("jpg") Then ListBox1.Items.Add(oFile.Name) If oFile.Name.EndsWith("JPG") Then ListBox1.Items.Add(oFile.Name) If oFile.Name.EndsWith("gif") Then ListBox1.Items.Add(oFile.Name) If oFile.Name.EndsWith("GIF") Then ListBox1.Items.Add(oFile.Name) Next Filename beinhaltet den kompletten Dateinamen samt Pfad der RAR-Datei RarPath beinhaltet den Pfad zur rar.exe in diesem Quellcode-Schnipsel soll die Rar-Datei in einen speziellen Ordner wntpackt werden. Anschliessend sollen alle Dateien mit den ENdungen jpg, JPG, gif, GIF in eine Listbox1 befördert werden. Habt Ihr eine Idee dazu warum das nicht mit allen RAR-Dateien funktioniert??? + Multi-Zitat Zitieren
#2 28. April 2009 AW: VB .NET 2008 entpacken per Command Line Hi, ich glaube um Zip Files zu entpacken musst du nen extra Parameter mitgeben. Winrar aufmachen --> Hilfe. Da gibts ne referenz. Gruß meckes + Multi-Zitat Zitieren
#3 28. April 2009 AW: VB .NET 2008 entpacken per Command Line Mach das lieber per DLL: unrar.dll: WinRAR archiver, a powerful tool to process RAR and ZIP files unzip.dll: Unzipping files using the free Info-Zip Unzip DLL with VB + Multi-Zitat Zitieren
#4 3. Mai 2009 AW: VB .NET 2008 entpacken per Command Line Sorry, wenn ich erst jetzt wieder auf dieses Thema zurückkomme, war leider die letzten Tage anderweitig beschäftigt ^^ ABer das mit der DLL macht mich noch wahnsinnig. Die Samples die dabei sind funktionieren in VB NET 2008 nicht mehr und mit Hilfestellungen von anderen Webseiten will auch nix funktionieren, wobei ich vermute, dass es nur dran liegt dass ich die DLL nicht als Verweis hinzufügen kann. Wenn ich es versuche, dann kommt ne Fehlermeldung, dass es keine gültige COM währe :-( + Multi-Zitat Zitieren
#5 3. Mai 2009 AW: VB .NET 2008 entpacken per Command Line Einfach per DLLimport einbinden bzw altmodisch per Declare Function MyFunction Lib "MeineDLL" etc... + Multi-Zitat Zitieren
#6 3. Mai 2009 AW: VB .NET 2008 entpacken per Command Line und genau mit der Variante "Declare Function....." schlage ich mich jetzt schon seit etwa 1 Stunde rum ^^ Was ist der DLLImporter? Das hört sich interessant an (Hab sowas vorher glaube ich noch nie gebraucht, bin also noch ein Noob was DLLs anbelangt ^^) + Multi-Zitat Zitieren
#7 3. Mai 2009 AW: VB .NET 2008 entpacken per Command Line Das ist kein "importer" das ist einfach ein Erstatz für Declace Function: http://www.devtrain.de/news.aspx?artnr=709 + Multi-Zitat Zitieren
#8 3. Mai 2009 AW: VB .NET 2008 entpacken per Command Line Ich glaube jatzt hab ichs geschafft^^ Ich hatte ihm anscheinend die Files nur ins falsche Verzeichnis gelegt (Hab auf einer anderen Seite gelesen, dass die in das Verzeichnis müssen wo er die EXE erstellt und nicht in das Verzeichnis in dem das Projekt liegt ^^) Jetzt wirft er mir nur noch eine Fehlermeldung aus: "Es wurde versucht, eine Datei mit einem falschen Format zu laden. (Ausnahme von HRESULT: 0x8007000B)" Ne Ahnung an was das liegen kann? denn mit Winrar selber bekomme ich die Datei ja auf Hier mal der Code den ich auf einer Webseite gefunden habe: Code: Private Const RAR_OM_LIST As Byte = 0 Private Const RAR_OM_EXTRACT As Byte = 1 ' Constantes de errores Private Const ERAR_NO_MEMORY As Byte = 11 Private Const ERAR_BAD_DATA As Byte = 12 Private Const ERAR_BAD_ARCHIVE As Byte = 13 Private Const ERAR_EOPEN As Byte = 15 Private Const ERAR_UNKNOWN_FORMAT As Byte = 14 Private Const ERAR_SMALL_BUF As Byte = 20 Private Const ERAR_ECLOSE As Byte = 17 Private Const ERAR_END_ARCHIVE As Byte = 10 Private Const ERAR_ECREATE As Byte = 16 Private Const ERAR_EREAD As Byte = 18 Private Const ERAR_EWRITE As Byte = 19 ' Constantes operaciones Private Const RAR_SKIP As Byte = 0 Private Const RAR_TEST As Byte = 1 Private Const RAR_EXTRACT As Byte = 2 ' Constantes del volumen Private Const RAR_VOL_ASK As Byte = 0 Private Const RAR_VOL_NOTIFY As Byte = 1 ' User Defined Types Structure RARHeaderData Dim ArcName As String Dim FileName As String Dim Flags As Long Dim PackSize As Long Dim UnpSize As Long Dim HostOS As Long Dim FileCRC As Long Dim FileTime As Long Dim UnpVer As Long Dim Method As Long Dim FileAttr As Long Dim CmtBuf As String ' Pointer (char *CmtBuf in C) Dim CmtBufSize As Long Dim CmtSize As Long Dim CmtState As Long End Structure Structure RAROpenArchiveData Dim ArcName As String ' Pointer (char *ArcName in C) Dim OpenMode As Long Dim OpenResult As Long Dim CmtBuf As String ' Pointer (char *CmtBuf in C) Dim CmtBufSize As Long Dim CmtSize As Long Dim CmtState As Long End Structure ' RAR DLL Public Declare Function RAROpen Lib "UnRAR.dll" Alias "RAROpenArchive" (ByRef RAROpenData As RAROpenArchiveData) As Long Public Declare Function RARClose Lib "UnRAR.dll" Alias "RARCloseArchive" (ByVal HandleToArchive As Long) As Long Public Declare Function RARReadHdr Lib "UnRAR.dll" Alias "RARReadHeader" (ByVal HandleToArcRecord As Long, ByRef ArcHeaderRead As RARHeaderData) As Long Public Declare Function RARProcFile Lib "UnRAR.dll" Alias "RARProcessFile" (ByVal HandleToArcHeader As Long, ByVal Operation As Long, ByVal DestPath As String, ByVal DestName As String) As Long Public Declare Sub RARSetChangeVolProc Lib "UnRAR.dll" (ByVal HandleToArchive As Long, ByVal Mode As Long) Public Declare Sub RARSetPassword Lib "UnRAR.dll" (ByVal HandleToArchive As Long, ByVal Password As String) ' ' código ' Function RARExtract(ByVal sRARArchive As String, ByVal sDestPath As String, Optional ByVal sPassword As String = "") As Integer ' Parámetros ' sRARArchive = nombre del fichero RAR ' sDestPath = Directorio de destino ' sPassword = Clave '(Opcional) ' REtorna ' Entero = 0 ' Falla() ' ' -1 Fallo al 'abrir el fichero RAR ' ' >0 'Número de ficheros extraidos Dim lHandle As Long Dim lStatus As Long Dim uRAR As RAROpenArchiveData Dim uHeader As RARHeaderData Dim iFileCount As Integer RARExtract = -1 ' Open the RAR uRAR.ArcName = sRARArchive uRAR.OpenMode = RAR_OM_EXTRACT lHandle = RAROpen(uRAR) [color=red]<- Hier bleibt er hängen mit dieser Fehlermeldung[/color] ' Failed to open RAR ? If uRAR.OpenResult <> 0 Then Exit Function ' Password ? If sPassword <> "" Then RARSetPassword(lHandle, sPassword) End If ' Extract file(s)... iFileCount = 0 ' Is there at lease one archived file to extract ? lStatus = RARReadHdr(lHandle, uHeader) Do Until lStatus <> 0 ' Process (extract) the current file within the archive If RARProcFile(lHandle, RAR_EXTRACT, "", sDestPath + uHeader.FileName) = 0 Then iFileCount = iFileCount End If ' Is there another archived file in this RAR ? lStatus = RARReadHdr(lHandle, uHeader) Loop ' Close the RAR RARClose(lHandle) ' Return RARExtract = iFileCount End Function Wenn ich die spezielle 64-Bit-Variante der UnRar.dll nehme dann bekomme ich zwar keine Fehlermeldung mehr, aber das Programm beendet sich automatisch sobald er versucht den Befehl "lStatus = RARReadHdr(lHandle, uHeader)" auszuführen + Multi-Zitat Zitieren