CFile Write and Read for all apps 
Author Message
 CFile Write and Read for all apps

Hi folks!

I wan to be able to acces a file and write a string with carrige return into
a it.
And then I want to be able to read it afterwords.

Well that seems to be quite easy ?
It will surely be but I'm a beginner and boths a Silly book and the msdn
coulnd't give me an example program.

You are all good so if you've got some time post me a program .
I would like to use CFILE

Please help me !!

Alexander Mahr



Thu, 31 Jul 2003 05:48:43 GMT  
 CFile Write and Read for all apps
http://www.cpp.atfreeweb.com/CFileSkeleton.html

For strings, you can use CStdioFile:

http://www.cpp.atfreeweb.com/CStdioFile.html


Quote:
> Hi folks!

> I wan to be able to acces a file and write a string with carrige return
into
> a it.
> And then I want to be able to read it afterwords.

> Well that seems to be quite easy ?
> It will surely be but I'm a beginner and boths a Silly book and the msdn
> coulnd't give me an example program.

> You are all good so if you've got some time post me a program .
> I would like to use CFILE

> Please help me !!

> Alexander Mahr



Thu, 31 Jul 2003 11:57:23 GMT  
 CFile Write and Read for all apps
Use CStdioFile to read/write text. Here is an example for writing:

  CStdioFile theFile;
  CString stringToWrite=_T("StringYouwanttowrite\n");

  if(!theFile.Open(fileName, CFile::modeWrite | CFile::typeText |
CFile::modeCreate))
  {
   TRACE("Cannot Open file\n");
   return;
  }

  CArchive archive(&theFile, CArchive::store);
  archive.WriteString(stringToWrite);
  archive.Close();
  theFile.Close();

--
Ajay Kalra [MVP - VC++]

Note: Please post all replies to newsgroup only.


Quote:
> Hi folks!

> I wan to be able to acces a file and write a string with carrige return
into
> a it.
> And then I want to be able to read it afterwords.

> Well that seems to be quite easy ?
> It will surely be but I'm a beginner and boths a Silly book and the msdn
> coulnd't give me an example program.

> You are all good so if you've got some time post me a program .
> I would like to use CFILE

> Please help me !!

> Alexander Mahr



Thu, 31 Jul 2003 15:49:09 GMT  
 CFile Write and Read for all apps


Fri, 19 Jun 1992 00:00:00 GMT  
 CFile Write and Read for all apps
THank you!!!

I know I can store string in a file.

CU



Thu, 31 Jul 2003 18:07:28 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Are CFile::Read() and CFile::Write() Really Unbuffered?

2. CFile vs CStdioFile problem writh reading / writing text

3. Problem with write using CFile and read using fscanf()

4. CFile::Seek and CFile::Read over the network

5. write to file with CFile::Write() failed

6. Reading ASCII float values with CFile.Read?

7. Reading a file with CFile::Read

8. Does CFile:Read() block on a read?

9. Reading/writing to an Access 2000 database through the Intenet using WIN32 app

10. Help wanted on reading/writing disk and writing your own OS

11. CFile::Write for formated strings.

12. CFile::Write and backslash codes.

 

 
Powered by phpBB® Forum Software