file copying program

This is a discussion on file copying program within the C++ Programming forums, part of the General Programming Boards category; how would a simple c++ console program be writting to copy a file from one location to another and overwriting ...

  1. #1
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608

    file copying program

    how would a simple c++ console program be writting to copy a file from one location to another and overwriting a file with its same name when it copies?
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  2. #2
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    hey, it's klinerr!!
    i can't answer your question because i'm really tired and can't comprehend what you said. oh well...
    welcome back.
    you left, right?

  3. #3
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    damn boy i remeber you from a long time ago in a galaxy far far away. didnt think anyeone woudl recognize me.

    anyways if your wondering where ive been than too bad i just got back a few weeks ago something like that. i finlly got a chance oout get out and do something though. great stuff
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,649
    Open the source file for reading (ifstream).
    Open the destination file for writting (ofstream).
    Read from the source and write to the destination.
    Close both files.

    Working with files faq.

    gg

  5. #5
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    thanks codeplug (im just getting back into this so half the commands are out of my brain) took me a long time to just make the simple setup with a cout line
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  6. #6
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    meh, try using CopyFile:


    http://msdn.microsoft.com/library/de...e/copyfile.asp

    CopyFile("C:\\myfile.txt","C:\\mynewfile.txt",true );

    returns false if the file mynewfile.txt already existed. set true to false to just overwrite the file instead of generating an error

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  2. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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