copying, then moving a file

This is a discussion on copying, then moving a file within the Windows Programming forums, part of the Platform Specific Boards category; using the windows api, how would I move a file which I have just copied using the below code? Code: ...

  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
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  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?
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    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, 04: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, 01:46 PM
  4. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21