Thread: open directory and copy files

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    2

    open directory and copy files

    well now

    the task:
    I want to open a directory, open the first file, [done] read some things, create a new name, [/done] copy the file to an other directory with a the new name and delete the old one. Then jump to the next file in the starting directory and do the same, then the next and so on...

    the problem:
    I neither know how to search for a random file (random name) in the directory, nor I know how to copy the file...
    I've tried to copy with getc and putc, getw and putw but none worked because they couldn't read a byte in the source-file and gave me an EOF... so the solution should be able to copy ANY byte in the file, not only chars or something like that...

    the system:
    I've used DEV-CPP on a win95...
    the final code should work with g++ on linux (mandrake AND FreeBSD if possible)

    so long
    5n4k3
    Last edited by 5n4k3; 08-07-2003 at 02:25 AM.

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    291
    You should look into
    FindFirstFile()
    FindNextFile()
    DeleteFile()

    Or

    Remove

    Please post your code and maybe someone could help out.

  3. #3

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    2
    ok thanks...
    this should solve the first one of my problems...
    the other one (how to copy a file byte-wise) still exists and needs to be solved

    so long
    5n4k3

    PS: to post the code might be a bit difficult since I wrote it on a non-net-pc at work

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 09:52 PM
  2. copy files to samba
    By lollobrigido in forum Linux Programming
    Replies: 3
    Last Post: 04-28-2008, 06:31 AM
  3. Finding files in a directory
    By smarta_982002 in forum C Programming
    Replies: 1
    Last Post: 01-25-2008, 10:10 AM
  4. I Need To Know Some Things That I Can Put Into A Batch File
    By TheRealNapster in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-20-2003, 08:12 PM
  5. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM