Thread: Saving with CFile (how)

  1. #1
    Caffienated jinx's Avatar
    Join Date
    Oct 2001
    Posts
    234

    Angry Saving with CFile (how)

    Hey evbdy. Iam.TheJinx(char *WhoCares);

    I need some help with some windows MSVC++. K, I use the:

    CFile myFile;
    &
    myFile.Open("C:\\...txt", CFile::modeRead);

    method to read and buffer in some text to a variable linked to an edit control. It works great. But I have tried every way I can think of to reload the varialbe and buffer out some the text with;

    void::OnSaveText();

    bn_clicked() handler. How can I buffer out the text in the variable to append it to a file that you can name, not just the standard way of declaring a set file, i.e.;

    myFile.Write("C:\\...txt", CFile::modeWrite);

    way.
    Thanks for any help on this.
    Weeel, itss aboot tieme wee goo back too Canada, eeehy boyss.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Look it up in your helpfile.

    <MSDN>

    nOpenFlags

    Sharing and access mode. Specifies the action to take when opening the file. You can combine options listed below by using the bitwise-OR (|) operator. One access permission and one share option are required; the modeCreate and modeNoInherit modes are optional. The values are as follows:

    CFile::modeCreate Directs the constructor to create a new file. If the file exists already, it is truncated to 0 length.


    CFile::modeNoTruncate Combine this value with modeCreate. If the file being created already exists, it is not truncated to 0 length. Thus the file is guaranteed to open, either as a newly created file or as an existing file. This might be useful, for example, when opening a settings file that may or may not exist already. This option applies to CStdioFile as well.


    CFile::modeRead Opens the file for reading only.


    CFile::modeReadWrite Opens the file for reading and writing.


    CFile::modeWrite Opens the file for writing only.


    CFile::modeNoInherit Prevents the file from being inherited by child processes.


    CFile::shareDenyNone Opens the file without denying other processes read or write access to the file. Create fails if the file has been opened in compatibility mode by any other process.


    CFile::shareDenyRead Opens the file and denies other processes read access to the file. Create fails if the file has been opened in compatibility mode or for read access by any other process.


    CFile::shareDenyWrite Opens the file and denies other processes write access to the file. Create fails if the file has been opened in compatibility mode or for write access by any other process.


    CFile::shareExclusive Opens the file with exclusive mode, denying other processes both read and write access to the file. Construction fails if the file has been opened in any other mode for read or write access, even by the current process.


    CFile::shareCompat This flag is not available in 32 bit MFC. This flag maps to CFile::shareExclusive when used in CFile::Open.


    CFile::typeText Sets text mode with special processing for carriage return–linefeed pairs (used in derived classes only).


    CFile::typeBinary Sets binary mode (used in derived classes only).

    </MSDN>

    The second one sounds like a good choice for appending.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CFile error
    By VirtualAce in forum Windows Programming
    Replies: 4
    Last Post: 04-23-2006, 04:22 PM
  2. New to C++ problem saving files
    By wesm in forum C++ Programming
    Replies: 2
    Last Post: 11-02-2005, 02:00 PM
  3. saving in linux
    By vanilly in forum Linux Programming
    Replies: 4
    Last Post: 02-15-2003, 08:10 AM
  4. CFile and reading data
    By filler_bunny in forum Windows Programming
    Replies: 6
    Last Post: 02-12-2003, 02:42 AM
  5. File saving problem in DevC++ pls help ???
    By intruder in forum C Programming
    Replies: 3
    Last Post: 12-17-2002, 01:17 AM