This tutorial will show you how to make a very simple builder and stub in C# which can be easily moded for use in your own projects.
Create a new project in visual studio for the builder and set up a form like this:
Spoiler (Click to View)
double click the button and write this code in the handler:
Spoiler (Click to View)
(dont forget to add to the using statements at the top of the code.)
the code displays a save file dialog and if the user chooses a filepath the stub is copied to it, the string split is used to determine where the info starts and end it can be whatever you want, the text in the textbox is then surrounded in the split, the FileStream is used to access the file and the BinaryWriter actually writes the data, by setting the position to the length + 1 we are writing to the end of file instead of somewhere were it could corrupt the program, the data is then written and the writer is closed.
Now create a new project for the stub only add a label to the form
Spoiler (Click to View)
double click the form and you will be taken to the load method, write this code there:
Spoiler (Click to View)
(dont forget to add to the using statements at the top of the code again.)
the first line creates a StreamReader at Application.ExecutablePath which is the path of the application running the code, the next lines read the binary data of the file, the last line maybe confusing but i will explain it,
the Enc.Getstring() coverts the binary data into a string of ascii characters, the substring method allows us to create a string from another string by specifying a position in it, for use the index of the split, now we have a string containing just the info we wrote to the file, the replace method replace the split with blank text so we have just what the user wrote in the textbox.
to test it build both projects and paste the stub.exe into the same directory as the builder.
Spoiler (Click to View)
please give feedback and suggestions.
Create a new project in visual studio for the builder and set up a form like this:
Spoiler (Click to View)
double click the button and write this code in the handler:
Spoiler (Click to View)
(dont forget to add
Code
System.IO;the code displays a save file dialog and if the user chooses a filepath the stub is copied to it, the string split is used to determine where the info starts and end it can be whatever you want, the text in the textbox is then surrounded in the split, the FileStream is used to access the file and the BinaryWriter actually writes the data, by setting the position to the length + 1 we are writing to the end of file instead of somewhere were it could corrupt the program, the data is then written and the writer is closed.
Now create a new project for the stub only add a label to the form
Spoiler (Click to View)
double click the form and you will be taken to the load method, write this code there:
Spoiler (Click to View)
(dont forget to add
Code
System.IO;the first line creates a StreamReader at Application.ExecutablePath which is the path of the application running the code, the next lines read the binary data of the file, the last line maybe confusing but i will explain it,
the Enc.Getstring() coverts the binary data into a string of ascii characters, the substring method allows us to create a string from another string by specifying a position in it, for use the index of the split, now we have a string containing just the info we wrote to the file, the replace method replace the split with blank text so we have just what the user wrote in the textbox.
to test it build both projects and paste the stub.exe into the same directory as the builder.
Spoiler (Click to View)
please give feedback and suggestions.
