I want to automaticaly manipulate each file in a directory. First thing is to be able ( and I have searched long nights unsuccessfully) to list files in a directory, then treat one at a time.
I'm writting a DOS console application, C++, win2000.
I want to automaticaly manipulate each file in a directory. First thing is to be able ( and I have searched long nights unsuccessfully) to list files in a directory, then treat one at a time.
I'm writting a DOS console application, C++, win2000.
you'll find the dir.h header has a lot of file/dir manip stuff
use findnextfile or something like that, getcwd, chdir etc functions to use files and dirs.
hope this gets you started.
-
HEY! Thanks........just the name of it looks promissing (dir.h)
I'm sure it's not in any of my books. I'll have to wait till I get to work to check it out... in any case...thank you very much.
Ok... I bumped into the same challenge recently... First of all, you'll need to find a way to get the file-name of each file ( sometimes directories pretend to be files too). To do this, you can use functions such as 'findfirst()' and 'findnext()' or any other funtion. Then you'll have to use a buffer to store the filename of each individual file. This is though. I'm using linked lists now, but it sometimes gives me problems when I bump into more than 100 or so files in one dir... so you c... If you do come out with anything better than me, please post a reply, coz i'm really interested in finding out...
Thanks
As a matter of fact, directories are files. They are just treated differently when encountered. DOS implements numerous disk I/O functions like findnext() and findfirst() via int 21h. Check out RBIL to view these interrupts or you can try to get your hands on a DOS tech ref. The disk I/O functions are far too numerous for me to list them here.
I know BASIC has a statement which will print (to the screen) a directory of a folder (just like typing DIR), but I have never been able to either manipulate so you could access that data as variables in a program, or found the C/ASM equivalent.