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. 3 3762
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: 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.
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" <No************ @comcast.netNoS pamM> wrote
in message news:B2******** *************** ***********@mic rosoft.com... 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:
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.
Just tried the DirectoryInfo and the FileInfo objects and they work
perfectly..
Now all I need to do is work out how to set up the FileWatcher Service...
Think I may be some time. :o)
Nick
"Cowboy (Gregory A. Beamer) - MVP" <No************ @comcast.netNoS pamM> wrote
in message news:B2******** *************** ***********@mic rosoft.com... 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:
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bart_nessux |
last post by:
Hello,
I have some Macbinary files on a PC. I want to recursively read these
files and remove the first 128 bytes of the files if they contain the
macbinary header info. I know how to read directories recursively, but
how would I read the first 128 bytes of each file in the path?
Thanks,
Bart
|
by: Joel Goldstick |
last post by:
I wanted to write a simple page to let me choose a directory and then list
the files in it. The end goal was to make an easy way to copy all the
file names in a directory. I tested with Opera7, Mozilla 1.4 and IE6 -- all
on windows XP Pro
Here is the code. In all three, when I select a file, the complete path
is displayed in the file input box. In Opera, reading the form field gives
me the same full path. But in IE and Moz I get...
|
by: mustafa |
last post by:
Assume that there are 100 flash files in a directory and i want to load 4
flash
files for every page and list of links in a row
(previousPage.page1.page1.page3.........page10.NextPage) How can i divide
100
files into pages and 4 filash files on every page. is it possible to use
files
|
by: milkyway |
last post by:
Hi ;-)
I have created a .aspx file that has the following:
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("TestInput.xml"));
As far as I can tell, the first line does not work - at all. I just get
"error" in the status field of the browser. How can I check to see what
|
by: Michael Palmer |
last post by:
I'm reading xml from SQL Server 2K with VB.net using an XSD schema file
and SQLXML 3.0. I have the below code working fine, but I'd like to change
the code from reading the schema file from a directory to reading the
schema as an embedded resource. Here's my current code, what would I need
to change??
Dim strm As Stream
Dim strmReader As StreamReader
Dim cmd As New SqlXmlCommand("MyConnectionString")
Dim xmlDoc As New XmlDocument
| |
by: Craig Vermeer |
last post by:
Hi All,
I have a program that's using the file system as a queuing mechanism,
and it's consuming an inordinate amount of CPU time when the file system
queue gets all that large (any more than a thousand or so messages in
the queue).
I know why. It's because my code to grab a single message off the queue
looks something like this :
|
by: farseer |
last post by:
Hi,
I am storing certain files in the same directory as an asp page. I'd
like for that page to be able to read read the names of the files in
that directory with a certain extension and create a hyperlink to them.
How can i do this.
as an example...
let's say my page resides at /mysite/dir1/default.aspx.
now in /mysite/dir1 are the files pic.jpg, pic1.jpg, pic2.jpg.
|
by: Laharl |
last post by:
My Operating Systems professor has assigned homework that basically boils down to implementing ls -lra, but with a different output format. In other words, list the files and subdirectories (and a bit of data about them, for the files) in the current directory and its subdirectories using system calls. Unfortunately, it isn't working quite right. It works fine in the current directory, but when it goes into subdirectories, the stat() function...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |