Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get random file

0 views
Skip to first unread message

shapper

unread,
Apr 15, 2008, 7:34:25 PM4/15/08
to
Hello,

I am displaying an image on a web site.
Is it possible to get a random file from a folder?

Thanks,
Miguel

Eliyahu Goldin

unread,
Apr 16, 2008, 4:56:05 AM4/16/08
to
Sure. Use System.IO.DirectoryInfo.GetFiles to get the list of files, use
method of the Random class to generate a random number between 0 and the
count of the files and select from the file list the file with the generated
index.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"shapper" <mdm...@gmail.com> wrote in message
news:c6469c1a-4536-44d0...@b64g2000hsa.googlegroups.com...

0 new messages