Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: elguast en 1 Agosto 2008, 13:28 pm



Título: juntar dos archivos
Publicado por: elguast en 1 Agosto 2008, 13:28 pm
me dice error en tiempo de ejecucion 52 nombre o numero de archivo:

Private Sub juntar_Click()
Dim Ap1 As String
Dim file As String
Dim Ext1 As String
Dim filed As String
Dim i As Integer
Dim nombre As String
If lista.ListCount < 2 Then
MsgBox "Seleciona más de un archivo", vbCritical, "Error"
Exit Sub
End If
ga.FileName = "Joiner"
ga.DialogTitle = "Guardar Como..."
ga.DefaultExt = "*.exe"
ga.ShowSave
FileCopy App.Path & "\stubb.dll", ga.FileName
For i = 0 To lista.ListCount - 1
Open lista.List(i) For Binary As #1
file = Space(LOF(1))
Get #1, , file
Close #1
filed = StrReverse(file)
file = ""
Text1.Text = lista.List(i)
Ext1 = Ext(Text1.Text)
nombre = Nam(Text1.Text)
Ap1 = Ap1 & "/separador/" & filed & "/separador/" & Ext1 & "/separador/" & nombre
Next
Open ga.FileName For Binary As #1
Seek (1), LOF(1) + 1
Put #1, , Ap1
Close #1
MsgBox "Archivos Juntados", vbOKOnly, "AVISO"
End Sub

a mi parecer lo tengo todo bien y no puedo juntar los dos archivos


Título: Re: juntar dos archivos
Publicado por: cobein en 1 Agosto 2008, 14:16 pm
Mira aca te de un ejemplo super simple para empaquetar archivos, lo arme en 5 min asi que no pretendas nada super, pero como base esta bien.

Código
  1. Option Explicit
  2.  
  3. Private Sub Form_Load()
  4.    Dim pbg As New PropertyBag
  5.  
  6.    SaveFile App.Path & "\text1.txt", StrConv("Test File 1", vbFromUnicode)
  7.    SaveFile App.Path & "\text2.txt", StrConv("Test File 2", vbFromUnicode)
  8.  
  9.    pbg.WriteProperty "File1", GetFile(App.Path & "\text1.txt")
  10.    pbg.WriteProperty "File2", GetFile(App.Path & "\text2.txt")
  11.  
  12.    Kill App.Path & "\text1.txt"
  13.    Kill App.Path & "\text2.txt"
  14.  
  15.    SaveFile App.Path & "\Pack.dat", pbg.Contents
  16.  
  17.    Set pbg = Nothing
  18.    Set pbg = New PropertyBag
  19.  
  20.    pbg.Contents = GetFile(App.Path & "\Pack.dat")
  21.  
  22.    SaveFile App.Path & "\text1.txt", pbg.ReadProperty("File1")
  23.    SaveFile App.Path & "\text2.txt", pbg.ReadProperty("File2")
  24.  
  25.    Kill App.Path & "\Pack.dat"
  26. End Sub
  27.  
  28. Private Function GetFile(sFile As String) As Byte()
  29.    Dim iFile As Long
  30.  
  31.    iFile = FreeFile
  32.    Open sFile For Binary Access Read As iFile
  33.    ReDim GetFile(LOF(iFile) - 1)
  34.    Get iFile, , GetFile
  35.    Close iFile
  36. End Function
  37.  
  38. Private Sub SaveFile(sFile As String, bvData() As Byte)
  39.    Dim iFile As Long
  40.  
  41.    iFile = FreeFile
  42.    Open sFile For Binary Access Write As iFile
  43.    Put iFile, , bvData
  44.    Close iFile
  45. End Sub
  46.