Get random file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    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
  • Eliyahu Goldin

    #2
    Re: Get random file

    Sure. Use System.IO.Direc toryInfo.GetFil es 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]




    "shapper" <mdmoura@gmail. comwrote in message
    news:c6469c1a-4536-44d0-8904-edc2daeb5abf@b6 4g2000hsa.googl egroups.com...
    Hello,
    >
    I am displaying an image on a web site.
    Is it possible to get a random file from a folder?
    >
    Thanks,
    Miguel

    Comment

    Working...