how to append conent to a 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
hongxing
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 227
Joined: Mon Aug 01, 2005 10:04 am

how to append conent to a file?

Post by hongxing » Wed Sep 21, 2005 2:05 am

wxFFile f;

file.Open("c:\\test.log", "wa"); // tested, but not correct.

I use "wa", "w" means create the file if it is not exists, "a" to append it
but "a" does not work.

priyank_bolia
wxWorld Domination!
wxWorld Domination!
Posts: 1339
Joined: Wed Aug 03, 2005 8:10 am
Location: BANGALORE, INDIA
Contact:

Post by priyank_bolia » Wed Sep 21, 2005 5:36 am

I don't think that you have to use "wa" only "a" is suitable, and it will create the file also if not found. Try it, may be works.

Vaulter
Earned a small fee
Earned a small fee
Posts: 19
Joined: Thu Jun 30, 2005 7:49 am
Location: Russia
Contact:

Post by Vaulter » Wed Sep 21, 2005 6:41 am

i always use that:

Code: Select all

wxFFile f;
f.Open("some","ab");//for not text.

[/code]

Jorg
Moderator
Moderator
Posts: 3971
Joined: Fri Aug 27, 2004 9:38 pm
Location: Delft, Netherlands
Contact:

Post by Jorg » Wed Sep 21, 2005 6:53 am

Just a small suggestion, why are you still using wxFFile? Isn't it more dynamic to use streams? After they were introduced there was basically no need for direct file I/O anymore, plus you can simply interchange one input stream kind with another with little to no effort.

Just a suggestion.

- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Wed Sep 21, 2005 6:58 am

Hi!
a combination like "wa" doesn't make sense, as "w" truncates the file. "a" implicitly means write access.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

hongxing
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 227
Joined: Mon Aug 01, 2005 10:04 am

thanks

Post by hongxing » Wed Sep 21, 2005 8:22 am

thanks to priyank_bolia, it works!

Post Reply