Question Help with creating a stub creator

RichyB

Member
Joined
Oct 9, 2009
Messages
6
Programming Experience
Beginner
What iv done is created 2 files one is a server file the other is a stub file.. what i want to do is input some information into server file and what it shud do is input that data into the stub file and create another copy of that file. So what i did to see if the information was getting passed over correctly i created 2 textboxes on the stub file and when u click the button it shows the variables / info i passed over.. Which is doesnt anyway here is the code if you dont mind having a look.

Server File
VB.NET:
Imports System.IO
Public Class Form1
    Dim stub, text1, text2, text3 As String  'Gives the name to the object to transfer. It could be anything.
    Const FileSplit = "@FileLink@" 'Name of the filesplit, you can change but it must be the same on builder and stub. (You must keep the @@)
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        text1 = TextBox1.Text 'Telling the program what the defined object equals.
        text2 = TextBox2.Text 'Telling the program what the defined object equals.
        FileOpen(1, Application.StartupPath & "\stub.exe", OpenMode.Binary, OpenAccess.Read, OpenShare.Default)
        stub = Space(LOF(1))                    '^^ The stub can be called anything, as long as the stub file is called that too.
        FileGet(1, stub) 'Collects the data from the stub.
        FileClose(1)
        If File.Exists("server.exe") Then 'Looks for a called "server"
            My.Computer.FileSystem.DeleteFile("server.exe") 'If it exists it will remove it.
        End If
        FileOpen(1, Application.StartupPath & "\server.exe", OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.Default) 'Creates the server an a directory, in this case the same as the builder.
        FilePut(1, stub & FileSplit & text1)
        FileClose(1)
    End Sub
End Class


Stub File
VB.NET:
Imports System.Net.Mail
Public Class Form1
    Dim options(), text1, Text2, Text3 As String  'Must be the same as in the builder "text1"
    Const FileSplit = "@FileLink@" 'Must be the same as in the builder "text1"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FileOpen(1, Application.ExecutablePath, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
        text1 = Space(LOF(1))
        text2 = Space(LOF(1))
        text3 = Space(LOF(1))
        FileGet(1, text1) 'Gets the information.
        FileGet(1, text2) 'Get the information.
        FileGet(1, text3) 'Get the information.
        options = Split(text1, FileSplit) 'Defines it as an option, this is option1.
        options = Split(text2, FileSplit) 'Defines it as an option, this is option2.
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = text1
        TextBox2.Text = Text2

    End Sub
End Class
 
Back
Top