473,770 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting number of files

I am trying to get the number of .jpg files in a given folder (to pick a
random one). The folder is referenced by a url - how can I do this. I have
tried the code below - but get an error that URLs are not accepted.
Dim files As String() = System.IO.Direc tory.GetFiles(d ir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunner y.org


Nov 18 '05 #1
10 1296
AFAIK System.IO.Direc tory is for file system based files.

If these files are on your local site, you'll have to convert the URL to a
physical location using Server.MapPath.

"bj daniels" <da******@gunne ry.org> a écrit dans le message de
news:ek******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get the number of .jpg files in a given folder (to pick a
random one). The folder is referenced by a url - how can I do this. I have tried the code below - but get an error that URLs are not accepted.
Dim files As String() = System.IO.Direc tory.GetFiles(d ir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunner y.org

Nov 18 '05 #2
Something like this might work?

Dim files As String() = System.IO.Direc tory.GetFiles(S erver.MapPath(d ir),
"*.jpg")

cheers,
mortb
Nov 18 '05 #3
They are not local to the site, they are on a separate site that is
dedicated to serving up media. I just don't want to start mapping drives or
creating shares. Is there an equivalent function that can work with a url
based path?

bj daniels
da******@gunner y.org


"Patrice" <no****@nowhere .com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
AFAIK System.IO.Direc tory is for file system based files.

If these files are on your local site, you'll have to convert the URL to a
physical location using Server.MapPath.

"bj daniels" <da******@gunne ry.org> a écrit dans le message de
news:ek******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get the number of .jpg files in a given folder (to pick a
random one). The folder is referenced by a url - how can I do this. I

have
tried the code below - but get an error that URLs are not accepted.
Dim files As String() = System.IO.Direc tory.GetFiles(d ir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunner y.org


Nov 18 '05 #4
> creating shares. Is there an equivalent function that can work with a url
based path?
No. Is the separate site on the same machine? If so, you can use the file
path to the folder in question. Otherwise, you're pretty much at the mercy
of whatever the "separate site" makes publicly available.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"bj daniels" <da******@gunne ry.org> wrote in message
news:OO******** ******@TK2MSFTN GP12.phx.gbl... They are not local to the site, they are on a separate site that is
dedicated to serving up media. I just don't want to start mapping drives or creating shares. Is there an equivalent function that can work with a url
based path?

bj daniels
da******@gunner y.org


"Patrice" <no****@nowhere .com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
AFAIK System.IO.Direc tory is for file system based files.

If these files are on your local site, you'll have to convert the URL to a physical location using Server.MapPath.

"bj daniels" <da******@gunne ry.org> a écrit dans le message de
news:ek******** ******@TK2MSFTN GP12.phx.gbl...
I am trying to get the number of .jpg files in a given folder (to pick a random one). The folder is referenced by a url - how can I do this.
I have
tried the code below - but get an error that URLs are not accepted.
Dim files As String() = System.IO.Direc tory.GetFiles(d ir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunner y.org



Nov 18 '05 #5
just tried that - it didn't work because the media is stored on a different
server.
thanks for the idea though.

bj daniels

"mortb" <mo****@hotmail .com> wrote in message
news:ep******** *****@TK2MSFTNG P09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Direc tory.GetFiles(S erver.MapPath(d ir),
"*.jpg")

cheers,
mortb

Nov 18 '05 #6
Either a request (? WebDav) or perhaps expose this info from the other site.
If the other site handles media files, how are they exposed ?

Patrice
"mortb" <mo****@hotmail .com> a écrit dans le message de
news:ep******** *****@TK2MSFTNG P09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Direc tory.GetFiles(S erver.MapPath(d ir),
"*.jpg")

cheers,
mortb

Nov 18 '05 #7
I just reference the url of the media I want (generally jpg) - it allows us
not to have to move media all over our site easily. this other site,
doesn't have any code.

bj

"Patrice" <no****@nowhere .com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Either a request (? WebDav) or perhaps expose this info from the other site. If the other site handles media files, how are they exposed ?

Patrice
"mortb" <mo****@hotmail .com> a écrit dans le message de
news:ep******** *****@TK2MSFTNG P09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Direc tory.GetFiles(S erver.MapPath(d ir), "*.jpg")

cheers,
mortb


Nov 18 '05 #8
if there an easy way to make that info available? Is that what a web
service would do?

bj
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
creating shares. Is there an equivalent function that can work with a url
based path?
No. Is the separate site on the same machine? If so, you can use the file
path to the folder in question. Otherwise, you're pretty much at the mercy
of whatever the "separate site" makes publicly available.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"bj daniels" <da******@gunne ry.org> wrote in message
news:OO******** ******@TK2MSFTN GP12.phx.gbl...
They are not local to the site, they are on a separate site that is
dedicated to serving up media. I just don't want to start mapping drives or
creating shares. Is there an equivalent function that can work with a
url based path?

bj daniels
da******@gunner y.org


"Patrice" <no****@nowhere .com> wrote in message
news:%2******** *******@TK2MSFT NGP11.phx.gbl.. .
AFAIK System.IO.Direc tory is for file system based files.

If these files are on your local site, you'll have to convert the URL

to a physical location using Server.MapPath.

"bj daniels" <da******@gunne ry.org> a écrit dans le message de
news:ek******** ******@TK2MSFTN GP12.phx.gbl...
> I am trying to get the number of .jpg files in a given folder (to
pick
a > random one). The folder is referenced by a url - how can I do this. I have
> tried the code below - but get an error that URLs are not accepted.
> Dim files As String() = System.IO.Direc tory.GetFiles(d ir, "*.jpg")
>
> result = files.Length
>
>
>
> thanks
>
>
>
> bj daniels
>
> da******@gunner y.org
>
>
>
>



Nov 18 '05 #9
One possibility: If the files reside in a folder that doesn't contain a
default page, and if the web server allows directory browsing, you could use
a WebRequest to the folder, which should get back a page with a listing of
all the files in the directory. You could then parse that page and get the
file listing out of it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"bj daniels" <da******@gunne ry.org> wrote in message
news:ut******** ******@TK2MSFTN GP12.phx.gbl...
I just reference the url of the media I want (generally jpg) - it allows us not to have to move media all over our site easily. this other site,
doesn't have any code.

bj

"Patrice" <no****@nowhere .com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Either a request (? WebDav) or perhaps expose this info from the other

site.
If the other site handles media files, how are they exposed ?

Patrice
"mortb" <mo****@hotmail .com> a écrit dans le message de
news:ep******** *****@TK2MSFTNG P09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Direc tory.GetFiles(S erver.MapPath(d ir), "*.jpg")

cheers,
mortb



Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2059
by: Jenny Zhang | last post by:
Hi, I am running OSDL-DBT3 test against PostgreSQL. I found performance difference between the runs even though the data and queries are the same. I tried to study this problem by getting execution plans at the beginning of each test. The following script gets execution plan for 22 queries, except query 15. i=1 while
5
11558
by: Dave Sisk | last post by:
Hey folks: I'm trying to do this: CREATE TRIGGER datawhse.emp_ti AFTER INSERT ON emp REFERENCING NEW AS n FOR EACH ROW MODE DB2ROW BEGIN DECLARE v_rrn DECIMAL(15,0);
17
16005
by: Arnold | last post by:
Is using fseek and ftell a reliable method of getting the file size on a binary file? I thought I remember reading somewhere it wasn't... If not what would be the "right" and portable method to obtain it? Thanks.
6
7731
by: Martin | last post by:
Hi all. I am developing a filemanager that needs to handle big files. While testing on some zipped files of 6-7GB each I noticed that filesize(), filemtime() and similar php-functions can't handle fikles larger than 2GB. This is true on the two servers I have regular access to (one php4-RedHat, the other php5-Fedora). If there a way to ger around these functions somehow? My fallback plan is to use the systems functions and then parse...
41
3536
by: LayneMitch via WebmasterKB.com | last post by:
I was just chating with a few webdevelopers and it was brought to my attention that I need some type of server technology installed on my computer so I could get a visual of how my sites would look on the web. I'm completely new to the server technology stuff and don't need anything expensive - only for testing purposes and so other web artists can see my work and give me their opinion/suggestions. What is the process of getting...
13
2816
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are used in multiple files, I have php files under / home/user/www/functions/. These files simply have So, in index.php and other files, I have
185
7132
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will return the file name given a FILE *. Questions: What would be the best name for this function?
5
1643
by: tshad | last post by:
I have the following class in my VS 2008 project that has a namespace of MyFunctions. ********************************* Imports System Imports System.Text.RegularExpressions Namespace MyFunctions Public Class BitHandling
0
1519
by: ppletkov | last post by:
Hi - I apologize if this is a simple question in advance :-) (hopefully it is so its quickly resolved!) i'm trying to figure out why i keep getting an error (Compile Error : expected function or variable) for my .find method. I have checked the format of this statement and it appears correct...? Dim ItemNumberWLO As String Dim ItemNumberWLN As String While Not WLO.EOF
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9453
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10099
jinu1996
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...
1
10036
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,...
0
9904
tracyyun
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...
0
8929
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
isladogs
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...
0
5354
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...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.