Thread: Win API file problem

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    18

    Question Win API file problem

    The following section of code is in my encryption programme that I am developing.
    If the file doesn't exist, there is no problem with writing the character string to the file.
    However, if I am overwriting the file, I cannot write the character string to the file. Just a blank file is produced.


    ofstream CiphertextF;

    CiphertextF.open(cipherfilename, ios:ut|ios::noreplace);
    if(!CiphertextF.is_open())
    {
    if(MessageBox(hwnd, "File Already Exists, Overwrite?","warning", MB_YESNO|MB_ICONQUESTION)==IDYES)
    CiphertextF.open(cipherfilename, ios:ut | ios::trunc);
    else
    break;
    }
    ....more code that is exectuted whether or not the file exists,
    ....including create ciphertext
    ....
    ....
    Ciphertextf<<ciphertextstring<<endl;



    any help would be much appreciated.
    Thanks,
    Donal

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    18
    Somebody must have an idea of what I am doing wrong???
    thanks,
    Donal

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. read from file problem
    By Martin Kovac in forum C Programming
    Replies: 1
    Last Post: 04-13-2009, 08:33 AM
  3. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  4. Subtle(?) File I/O Problem
    By cecomp64 in forum C Programming
    Replies: 9
    Last Post: 07-16-2008, 11:39 AM
  5. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM