Thread: Copying exe file

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    Copying exe file

    I have a program that copies a file to another.... it uses the fstream functions... It works fine when i copy text files but when i try to copy exe's or other files the copied file is corrupt.. I even tried the ios::binary mode.. But it still does not work.. I think the problem is i copy character by character till end of file(EOF) is encountred.. Since the exe's may have -1 some where in between it terminates there.. this is my guess.... So how do i make the prog work.....



    Thanx
    Vasanth

  2. #2
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719
    At a point like that I would resort to using API calls to read files.

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    Well i am not using VC++ or anything.. I am using TC++ (turbo c++) which only supports 16 bit DOS applications..

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    You should try to get the real size of the file. Then don't read until EOF but until you have read the correct size. that way you can copy the eof char to.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  2. Basic text file encoder
    By Abda92 in forum C Programming
    Replies: 15
    Last Post: 05-22-2007, 01:19 PM
  3. text file copying incorrectly
    By IsmAvatar2 in forum C Programming
    Replies: 2
    Last Post: 05-13-2007, 11:23 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM