for a program i am making i need to find a completely random file on the HD, basicly i want it to determine a random directory, then find a random file within that directory, i have NO clue where to begin on this one, i have read some stuff about getting directory lists
im thinking itll have to be a recursive function that puts all of the directories in the top of the HD in an array then chooses one at random, then it opens that directory, then it looks for files, if it finds files then it decides whether or not to look for more folders or open a file, if it (like a 1 in 4 chance to open the file if theres folders there), if it opens a file it chooses one in a similar manner that it chooses directories. if it decides to choose a directory it repeats itself. if it ends up in a directory with no files it should automaticly just up to the previous directory. i hope this makes sense... i just need to know the functions/syntax to do this, i can figure out most of it, but without a function(s) that takes directory names and puts them into subs in an array im lost =/
im thinking itll have to be a recursive function that puts all of the directories in the top of the HD in an array then chooses one at random, then it opens that directory, then it looks for files, if it finds files then it decides whether or not to look for more folders or open a file, if it (like a 1 in 4 chance to open the file if theres folders there), if it opens a file it chooses one in a similar manner that it chooses directories. if it decides to choose a directory it repeats itself. if it ends up in a directory with no files it should automaticly just up to the previous directory. i hope this makes sense... i just need to know the functions/syntax to do this, i can figure out most of it, but without a function(s) that takes directory names and puts them into subs in an array im lost =/