Results 1 to 7 of 7

Thread: Merging Files

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    84

    Merging Files

    I lost the code to a program I made quite a while back so I was wondering if any one could help.

    I have a list box which has file locations loaded into it by the user

    After they are loaded they click the merge button and it joins all the files loaded into the listbox into 1 exe

    I have this code I upgraded from vb6. I think it is joining the files but only the first one in the list is opening when i run the new exe that is made when they are merged

    Code:
    Dim sfd As New SaveFileDialog
            If sfd.ShowDialog() = DialogResult.OK Then
    
                Dim incoming As String
                FileOpen(1, sfd.FileName, OpenMode.Append)
    
    
                For i = 0 To ListBox1.Items.Count - 1
    
    
                    FileOpen(2, Me.ListBox1.Items.Item(i), OpenMode.Binary)
                    incoming = Space(LOF(2))
    
                    FileGet(2, incoming)
                    FileClose(2)
    
                    PrintLine(1, incoming)
                Next i
    
                FileClose(1)
            End If

  2. #2
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Merging Files

    What are the actual files you are "merging"?

    It seems an odd thing to try and combine executable files together in this manner - I'm pretty surprised that anything runs at all, but if it does run something I can't see how you could possibly expect it to execute anything other than just the first EXE in the new merged file.

    A little more explanation is needed I think.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    84

    Re: Merging Files

    Quote Originally Posted by keystone_paul View Post
    What are the actual files you are "merging"?

    It seems an odd thing to try and combine executable files together in this manner - I'm pretty surprised that anything runs at all, but if it does run something I can't see how you could possibly expect it to execute anything other than just the first EXE in the new merged file.

    A little more explanation is needed I think.
    well this isn't the original code i used when i first made the program a year or so ago.

  4. #4
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Merging Files

    Can you explain what you are expecting?

    As far as I can see your code will take two files and join them together, but if you were to combine say "notepad.exe" and "calculator.exe" into a single executable in this manner, what are you expecting to happen when you run the new executable?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2008
    Posts
    84

    Re: Merging Files

    I expect them to both open

  6. #6
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: Merging Files

    That simply isn't possible. An executable file has only one starting point so there's no way it is going to run them both.

    You could write a program that embedded executables as resources and at runtime extracted each one and ran it, but that is not the same as just merging two existing executables into one.
    Last edited by keystone_paul; Jun 11th, 2009 at 04:50 AM.

  7. #7
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: Merging Files

    You coud write a small executable that attaches other executables to itself, binary style and stores the lengths of the executables, the breaks pieces of itself off as necessary and runs them.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width