Thread: copying, then moving a file

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Thumbs up copying, then moving a file

    using the windows api, how would I move a file which I have just copied using the below code?
    Code:
    char FileName[] = 'myFile.txt';
    char NewName[] = 'newFile.txt';
    char NewDir[] = 'C:\\folder\\';
    
    // Tell me if i've called this function incorrectly...
    BOOL CopyFile(FileName, NewName,); // copy the file
    
    // what do I put here to move this copied file?
    Thanks for any help
    -Chris

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    to copy, and overwrite exisiting file:
    Code:
    if(CopyFile(FileName, NewName, FALSE))
    {
      // success
    }
    to copy, but don't overwrite exising file:
    Code:
    if(CopyFile(FileName, NewName, TRUE))
    {
      // success
    }
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  3. #3
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Yes, but how would I move that copy of the file to another folder?

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    char NewFile[] = "c:\\windows\\";
    strcat(NewFile, NewName);
    CopyFile(FileName, NewFile, FALSE);

    would be my guess, but I've never used the function...

    Another idea would be to read in the file, and write it to the new folder under the same name.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can we have vector of vector?
    By ketu1 in forum C++ Programming
    Replies: 24
    Last Post: 01-03-2008, 05:02 AM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM