Get random file

Hello,

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

Thanks,
Miguel
Shapper [ Mi, 16 April 2008 01:34 ] [ ID #1943395 ]

Re: Get random file

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" <mdmoura [at] gmail.com> wrote in message
news:c6469c1a-4536-44d0-8904-edc2daeb5abf [at] b64g2000hsa.google groups.com...
> 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 [ Mi, 16 April 2008 10:56 ] [ ID #1943422 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » Get random file

Vorheriges Thema: How to Determine User Input
Nächstes Thema: RE: Register Javascript code.