Hi! I'm a newbie in wxwidgets, I use codeblocks as my IDE, I recently embarked on a project to create a sort of jotter like app for instantly saving texts and loading them with emphasis on speed... But that's another story.
I originally started the project using basic C++ File save via fstream/ofstream but after that backfired I sought to use the famous wxtextfile, but every tutorial I find never seems to hit the point of a simple save example, so please can I get a good example of a Textfile save from a textctrl with a wxstring?
Thanks in advance!
wxTextFile Confusion Topic is solved
-
- Knows some wx things
- Posts: 30
- Joined: Tue Dec 11, 2018 1:38 pm
Re: wxTextFile Confusion
What exactly was wrong with that?using basic C++ File save via fstream/ofstream but after that backfired
wxTextFile is good for accessing a textfile on a line-by-line basis, from your description it doesn't sound like it's the right tool for the job.I sought to use the famous wxtextfile, but every tutorial I find never seems to hit the point of a simple save example
Just use wxFile:
Code: Select all
wxString s = "a string from somewhere";
wxFile f( "d:\\test.txt", wxFile::write );
f.Write( s ); // saves using UTF8 encoding
f.Close();
Use the source, Luke!
-
- Knows some wx things
- Posts: 30
- Joined: Tue Dec 11, 2018 1:38 pm
Re: wxTextFile Confusion
Thanks Very Much for your Reply and Advice, I really appreciate it!
About your question. It Backfired in the sense I couldn't save a file with a user input file name... I tried so hard, even porting in string variables to replace the file name which obviously wasn't applicable and also the fstream class is too rigid to be ported with wxwidgets almost everything I tried resulted in error.
Thanks again! I'll try it out now
About your question. It Backfired in the sense I couldn't save a file with a user input file name... I tried so hard, even porting in string variables to replace the file name which obviously wasn't applicable and also the fstream class is too rigid to be ported with wxwidgets almost everything I tried resulted in error.
Thanks again! I'll try it out now
- shawnhcorey
- Knows some wx things
- Posts: 41
- Joined: Mon Nov 19, 2012 3:29 pm
- Location: The Great White North
Re: wxTextFile Confusion
Some things you might check for:
Does the user have write permissions on the directory?
Is the file being written to the root directory?
Does the name contain characters, like spaces, that the OS does not allow?
Some OSes require an extension on every file. Does the name have an extension?
Does the user have write permissions on the directory?
Is the file being written to the root directory?
Does the name contain characters, like spaces, that the OS does not allow?
Some OSes require an extension on every file. Does the name have an extension?
WARNING: Highly caffeinated . Approach with caution .
-
- Knows some wx things
- Posts: 30
- Joined: Tue Dec 11, 2018 1:38 pm
Re: wxTextFile Confusion
Thanks I'll check on them..