Re: Randomly Assign File

Discussion in 'ASP .Net' started by Jack Moskowitz, Aug 23, 2003.

  1. You can use System.IO.Directory.GetFiles() to get a list of all files in a
    directory. Then use System.Random() to generate a number that you can use
    to pick one of the files from the list. From this, generate the path to the
    file as a string and use that as the src parameter in an <img> tag.

    --jack


    "brian" <> wrote in message
    news:012701c367f5$1a9ed090$...
    > Hello,
    >
    > I am looking for help on changing the picture that is
    > loaded on my intranet page. I would perfer not to use an
    > ad rotator.
    >
    > On the form load I would like to have the page search
    > thru directory 'c:/comics' (which holds about 10,000
    > strips) and randomly pic a strip to place on the page.
    >
    > My knowledge is limited with .NET and am a novice
    > programmer. I assume I will have to declare a variable
    > that will be assigned the comic strip file name that is
    > picked randomly. And place that variable in the image
    > source location.
    >
    > So, can someone help me randomly assign a file name to
    > the declared varable:
    > Dim File as string
    >
    > Also, when the file is assigned does the file extension
    > carry over too?
    >
    > Thank You
    >
    >
    >
    >
    Jack Moskowitz, Aug 23, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Ter-Saakov

    Re: Randomly Assign File

    George Ter-Saakov, Aug 21, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    362
    George Ter-Saakov
    Aug 21, 2003
  2. rohit

    randomly write to a file

    rohit, May 7, 2007, in forum: Python
    Replies:
    11
    Views:
    453
    Dennis Lee Bieber
    May 8, 2007
  3. =?Utf-8?B?TWFydGluSg==?=

    Upload file functionality fails randomly

    =?Utf-8?B?TWFydGluSg==?=, May 8, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    306
    Walter Wang [MSFT]
    May 14, 2007
  4. Jonathan Wood
    Replies:
    0
    Views:
    604
    Jonathan Wood
    Jan 23, 2008
  5. Zachary
    Replies:
    76
    Views:
    477
    Matt Garrish
    Apr 30, 2006
Loading...

Share This Page