GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 22-Jul-2004, 21:33
w332 w332 is offline
New Member
 
Join Date: Jul 2004
Posts: 4
w332 is on a distinguished road
Unhappy

going crazy over file copy !


Im going crazy over this piece of code, it compiles but the exe is huge
and it doesent copy corectly, the file in program files is 0 kb.. (so empty)
could annybody please tell me what to change or maybe use another
command.. (what i basicly want to do is copy the file that is being
executed to another directory)
thanx for help !!!

Code:
CPP / C++ / C Code:
const char *src = "\\instal.exe";
ifstream input(src,ios::binary);

const char *dst = "c:\\Program Files\\myprogram.exe";
ofstream output(dst,ios::binary);

output <<input.rdbuf();
Last edited by LuciWiz : 25-Mar-2006 at 12:39. Reason: Please insert your C++ code between [c++] & [/c++] tags
  #2  
Old 22-Jul-2004, 23:46
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by w332
Im going crazy over this piece of code, it compiles but the exe is huge
and it doesent copy corectly, the file in program files is 0 kb.. (so empty)
could annybody please tell me what to change or maybe use another
command.. (what i basicly want to do is copy the file that is being
executed to another directory)
thanx for help !!!

Code:
Code:
const char *src = "\\instal.exe"; ifstream input(src,ios::binary); const char *dst = "c:\\Program Files\\myprogram.exe"; ofstream output(dst,ios::binary); output <<input.rdbuf();
I just built and ran the program and it worked fine:
CPP / C++ / C Code:
#include <fstream>
using namespace std;

int main()
{
    const char *src = "text.txt";
    ifstream input(src,ios::binary);

    const char *dst = "text1.txt";
    ofstream output(dst,ios::binary);

    output <<input.rdbuf();

    return 0;
}
How big is the file you're trying to copy? I tested it on a file 7,225,832 bytes.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
 
 

Recent GIDBlogToyota - 2008 November Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CD burner wont burn!! robertli55 Computer Hardware Forum 1 18-Jun-2004 11:53
Yet another CD burner problem: Lite-On LSC-24082K Erwin Computer Hardware Forum 1 22-May-2004 12:28
Read file and copy to dinamic array Carlo C++ Forum 3 10-May-2004 20:28
Re: Programming Techniques WaltP C Programming Language 0 10-Mar-2004 00:56

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:30.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.