0

Hello,

i am trying to write a C program to copy a file from one directory and copy that to another directory. I am new to file handling and dont know how to proceed further. could you please guide me how to implement the property in the c code to copy a file.


Thanks

3
Contributors
10
Replies
15
Views
5 Years
Discussion Span
Last Post by WaltP
Featured Replies
  • Open the original file for reading. Open the new file for writing. Then in a loop read a block of data from the input file and write it back out to the output file. Since we don't know whether the original file was write in text or binary mode its … Read More

  • 1
    WaltP 2,905   5 Years Ago

    [QUOTE=kumarmpk4u;1546852]is it possible to copy a zip file and exe file from one directory to another using c program?[/QUOTE] Yes. Read More

  • Just how many times do I have to tell you how to do it. I answered that question three days ago in this thread ([URL="http://www.daniweb.com/software-development/c/threads/361633/1545008#post1545008"]here[/URL]) Read More

1

Open the original file for reading. Open the new file for writing. Then in a loop read a block of data from the input file and write it back out to the output file. Since we don't know whether the original file was write in text or binary mode its always safest to assume binary mode. And I like to read blocks of data in chuncks of 255 bytes, but you can make it almost anything you want.

open input file in binary mode
open output file in binary mode
loop
   read a block of data from input file
   write the block to output file
end of loop
close both files
Comments
His views helps me a lot
0

hi Man,
Thank you for your reply.
Could you please give me some sample codes or links containing that.
Also the requirement of my project is that i have to check the contents of the file first and copy the contents of a file which is present in some other directory.

0

You give it a try yourself, then post back with the code you have written if you have more questions. Yes you may have to do some studying about FILE* and associated functions which I can not do for you. Also google around for c file handline tutorials to help you out with your research. Nothing teaches you better than when you research and discover the solutions to these things yourself.

0

is it possible to copy a zip file and exe file from one directory to another using c program?

1

is it possible to copy a zip file and exe file from one directory to another using c program?

Yes.

-1

do we have any specific commands to perform that?
could you please guide me with a sample code...

Thanks

0

I guess you want us to write the program for you. Ain't going to happen in this lifetime. Show us that you have made an effort and posted the code you have written.

0

i didnt ask for a program... i asked whether there is any specific method to copy a exe file or zip file.

0

i didnt ask for a program... i asked whether there is any specific method to copy a exe file or zip file.

No.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.