Writting into file... Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
coder89
Experienced Solver
Experienced Solver
Posts: 77
Joined: Fri May 23, 2008 9:01 am

Writting into file...

Post by coder89 »

Hello.
I'm using wxTextInputStream class to read line of wxString from file. Then I operate on it.

Now I want to add the result of my operations in place of the read line without losting the other lines...

This is the sample

Code: Select all

// Opened file before edition
Firstline....\n
SecondLine....\n
ThirdLine....\n

// Now i read Second Line
// And operate on it...

// Writting into file
Firstline....\n
EDITEDLINEASHFUASFHUAHSIFUASHFAIFSH....\n
ThirdLine....\n
Pleas help how to do this...
Thnx.
timg
Earned some good credits
Earned some good credits
Posts: 148
Joined: Mon Jan 23, 2006 6:52 pm

Post by timg »

If the file is not large, you might find it easier to use wxTextFile to read and modify your file.
chris_bern
Earned some good credits
Earned some good credits
Posts: 125
Joined: Wed Mar 05, 2008 3:30 pm

Post by chris_bern »

Read the file using loop and put each line as an element of a string array. Then use the index of the array to work on the content.

Chris
coder89
Experienced Solver
Experienced Solver
Posts: 77
Joined: Fri May 23, 2008 9:01 am

Post by coder89 »

I would like to write a setting file pharser...
There will be only 8-10 lines (values).
It may look like that => "username=root" and the "root" walue will be cut from this line using wxRegex.

Maybe there is a better class (classes) to do this??
vdell
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Post by vdell »

coder89 wrote:Maybe there is a better class (classes) to do this??
Are you trying to parse config files? If yes then have a look at wxFileConfig.
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere
Post Reply