Jump to content
Sign in to follow this  
bubke

Random read files from a directory

Recommended Posts

bubke

Hello,

Does anyone have an example for random reading files from a directory? I want to read a sequence of files, but the program must it read random.

To read files from a directory is no problem, but i can't figure it out how to do it random.

Grtz, bubke

Share this post


Link to post
Share on other sites
Achilles

Look at the functions _FileListToArray and Random..

You could use _FileListToArray to find out all the files in an directory, and then random to get a random file.

This is an untested version of what you want to do:

$temp = _FileListToArray("C:\", "*.*", 1) 
FileRead($temp[Random(1, UBound($temp) - 1])

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.