| re: Reading a list of files from a directory
Awesome..
Thanks Gregory.
Never used the DirectoryInfo object but will look it up in the help files.
I'm very new to asp.net so you've lost me a little with the FileWatcher
service (although understand the XML concept), I'll scan the help etc for
info.
Many thanks.
Nick
"Cowboy (Gregory A. Beamer) - MVP" <NoSpamMgbworld@comcast.netNoSpamM> wrote
in message news:B2446B1E-56EF-41BA-8C43-F31F7F2660F5@microsoft.com...[color=blue]
> 1. Get the actual directory to search it, rather than the URL.
> 2. Set up a DirectoryInfo object and point to that directory
> 3. Loop through the directory Info files collection
> 4. Grab file name and append the relative URL to it
>
> You should be able to handle the image display, as you are already doing
> that.
>
> NOTE: Another option is to have a piece of code that runs through the
> directory and creates an XML file with the image links. You can have this
> automatically set up, as a FileWatcher service, for example, or have it
> run
> when you kick it off. The benefit here is you do not have to rescan images
> every hit on the page. If you do the non-watcher version, you can also
> publish images before you are ready to show them and rescan when you are
> ready.
>
>
> ---
>
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
>
> ***************************
> Think Outside the Box!
> ***************************
>
>
> "Nick" wrote:
>[color=green]
>> Is it possible to read a list of files from a specified directory using
>> VB.net
>>
>> We have company intranet and I have created a page that displays photos
>> from
>> different events.
>> I have coded a page that display images from a particular directory and
>> named the files Pic1.jpg, Pic2.jpg etc. My code then cycles through the
>> images and displays them in the browser. I store the current image number
>> in
>> a session variable and apply it to the image control when the page is
>> loaded. The user then clicks a button to go to the next image.
>>
>> To be honest all this works absolutely fine. If I add pictures I have to
>> rename the new files and change a constant in my code so that you can't
>> browse past the last image. This really isn't much of a probelm, but I
>> was
>> wondering if there was a way of reading the contents of a directory using
>> vb.net and store them say in the cache object as an array. That way I can
>> get the number of files dynamically rather that having to recode.
>>
>> Just curious and hoping to expand on the little bit of knowledge I have.
>>
>> Many thanks in advance
>> Nick.
>>
>>
>>
>>
>>
>>[/color][/color] |