Button/Textbox combo to edit part of a line in a .text file using Visual Studio 2010?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
I am building a level editor for a game i have as a bit of a programming learning experience as im quite new to VB programming.
The game uses various .text (not .txt) files to define parameters for each level and to edit these i would need to access these files and be able to input new text into some of the existing lines. These lines are in macro blocks and the lines are in
different places in different files. The ability to edit existing text would be useful too.
The files reside within 4-5 different folders within the root game folder and there is some cross-relation between some of the files i.e. changes in one file need to be reflected in another or several others.
Im looking at using a form with textboxes to input the new text with associated buttons that perform the updates.
The research ive done so far seems to point to StreamReader and StreamWriter methods or possibly DataGridView or ReadAll/WriteAll?
I also found this as a possible method:
String strFile = File.ReadAllText("c:\File1.txt");
strFile = strFile.Replace("oldvalue", "newvalue");
File.WriteAllText("c:\File1.txt", strFile);

Below is an short example of the type of files i want to edit/append:
loc_eng()<br/>
{<br/>
<br/>
<span style="white-space:pre txt_cm_ camp_stu_1 () {
Tigers in the Mist ; }<br/>
<br/>
<span style="white-space:pre txt_mc_ sbmission_1 () {
We Attack at Dawn! ; }<br/>
<span style="white-space:pre <br/>
<span style="white-space:pre txt_history_ sb_1 () {
This is my second mission .; }<br/>
<span style="white-space:pre <br/>
<span style="white-space:pre }<br/>
<span style="white-space:pre <br/>
}

The bold text are examples of what i might want to edit and as stated these files are in .text file and need to be to be read by the game engine. The formatting of these lines is obviously important so any editing or saving etc would need to leave
the formatting intact.
Any help would be really appreciated?
Many thanks.
Stu

View the full article
 
Back
Top