Copying a file

This is a discussion on Copying a file within the C++ Programming forums, part of the General Programming Boards category; Is there an *easyer* way of copying a file other than opening it, copying the contents to a string and ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    58

    Copying a file

    Is there an *easyer* way of copying a file other than opening it, copying the contents to a string and then inputing it into a file??
    --== www.NuclearWasteSite.com==--

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    depends on the operating system you are using. Most have some sort of copy file function.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    58
    Windows 98
    --== www.NuclearWasteSite.com==--

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    if you are writing a windows program then you can use CopyFile() or CopyFileEx()..... look them up at msdn for code samples and information
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    58
    ok i tryed going to msdn but i cant find any code, here's what i have so far, i know im not even close.

    [code]
    #include <iostream.h>
    #include <windows.h>

    int main()
    {
    char filename[50];

    cout<<"Filename: ";
    cin>>filename;

    CopyFileEx("a:\\blah.txt", filename, NULL);

    }

    This gives me only 1 error: ( the short version if it is) ERROR 32: too few peramiters.

    can some one take the code i just wrote and make it work PLEASE i know this is asking alot and asking some one to write ur program is wrong but for the life of me i cant figure it out.
    --== www.NuclearWasteSite.com==--

  6. #6
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You could use CopyFile instead of CopyFileEx if you don't need to use the extra parameters as it's alot simpler -

    CopyFile("blah.txt","copy",1);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 11:39 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 04:53 AM
  3. Need Help Fixing My C Program. Deals with File I/O
    By Matus in forum C Programming
    Replies: 7
    Last Post: 04-29-2008, 08:51 PM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 05:54 PM
  5. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

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