Copy all files of Directory into single file..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KaimTazz
    New Member
    • Aug 2007
    • 2

    Copy all files of Directory into single file..

    Hi everybody.
    I have an idea of reading one file and write it somewhere else. Now, suppose I have five(approx.) files in some directory and if all files are required to write in single file one by one then how it is to be done?? Any suggestion pls.
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    You posted in the C/C++ forum, so I'm going to assume you're trying to write a C/C++ program for that... So just keep the file output stream the same. You can open and close the file in put streams to be the five files, and then simply don't close the file output stream until all file files have been read.

    This is a pretty good tutorial on File I/O, and should get you started.

    Comment

    • KaimTazz
      New Member
      • Aug 2007
      • 2

      #3
      [Thanks for your post....

      I have Idea about what is there in the link you sent. but I dont want to read only single file. I want to read more than one files one by one and then put their contents in single file. There is some function like getnextfile() or getfilenext() to have pointer to next file. Pls suggest me in that way...

      Suppose at c:\data\ I have more than one files(actually not know at runtime) and we have to make program that copies content of one file(say Packet.txt) and call getnextfile() or getfile next() to know whether we have more file in folder or not. if yeah then copy its content to file(Packet.txt )...

      Comment

      • naivE
        New Member
        • Jun 2007
        • 12

        #4
        Originally posted by KaimTazz
        [Thanks for your post....

        I have Idea about what is there in the link you sent. but I dont want to read only single file. I want to read more than one files one by one and then put their contents in single file. There is some function like getnextfile() or getfilenext() to have pointer to next file. Pls suggest me in that way...
        Hey. I have had to do a few of these things in the project I am working on at the moment and they can get a little confusing. Google really comes in handy though http://www.developerfusion.co.uk/show/4359/ for example.
        You should be able to use this to get started. Also, it is probably worth thinking about subfolders too as they can be a bit of a hassle. Well, for me and my limited experience anyway.

        Good luck.

        Comment

        Working...