Flat file issue.

alex_cole

New member
Joined
Apr 19, 2006
Messages
2
Programming Experience
Beginner
Hello and thanks to anyone who can help. I have an app where I am writing data to a flat file (my programs config settings) when they leave the options page, When the application opens it opens the config file and reads the values stored in there to set the options. My problem is when I write the data to the file it is putting "" at the beginning and end of the data. Each time you go into the options it writes the data with another set of "" so after a wile you get stuff like this

"""""""""""test data'''''''''''''''''
'''''''''test notes'''''''''''''
1
1

THis causes issues when trying to re-read the data...I am storing some data paths.

Below is my function block that is writing data
---------------------------------------------------------------------
' ##################################################################
' ### Prepare data for output to config file
Call update_Vars()
On Error GoTo ErrorHandler
FileOpen(1, str_bnc_path, OpenMode.Output, OpenAccess.Write)
' open file so we can write data
WriteLine(1, str_img_path) ' write 1st line of info
WriteLine(1, str_notes) ' write next line of data
WriteLine(1, bnc_note_font_size) ' write next lin e of data
WriteLine(1, bnc_num_font_size) ' write next line of data
FileClose(1) ' close file

form_options.Hide() ' hide this form and exit options page
Exit Sub
----------------------------------------------------------------------

This is my code to read
Private Sub frm_printerForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
str_bnc_path = "C:\program files\Number\settings.bnc"
' setup directory and name for config file
On Error GoTo ErrorHandler
FileOpen(1, str_bnc_path, OpenMode.Input, OpenAccess.Read)
' open file so we can read in the data
str_img_path = LineInput(1) ' input the 1st line of data into a variable
str_notes = LineInput(1) ' input the next line of data
bnc_note_font_size = LineInput(1) ' input the next line of data
bnc_num_font_size = LineInput(1) ' input the next line of data
FileClose(1) ' Close file.
cbo_notes_font_size.SelectedIndex = bnc_note_font_size ' take val read from file and update the note font size with val
cbo_num_font_Size.SelectedIndex = bnc_num_font_size ' take val read from file and update into the Number font size
rtb_notes.Text = str_notes ' take the terms/notes and feed them into the notes rich text box.
pic_logo.Image = Image.FromFile(str_img_path) ' take the image file saved and feed it into the picture box
Exit Sub
------------------------------------------------------------------------

Another issue I am having is that I have a RichTextBox that is holding multiline notes. I was using the printline method but it would print a new line in the flat file when someone entered a return to space down in the RTB.

Any ideas??

Thanks

Alex
 
It looks like somewhere after you read the data you are putting quotes around it, then when you write it back you are writing the quotes as part of the string, and when writing it back to file the quotes are included. so each time adds another set of quotes.

If your lazy and dont figure it out just after you read the variables do whateverstring.replace("""","")
 
Back
Top