By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 916 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

getting number of files

P: n/a
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.Directory.GetFiles(dir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunnery.org


Nov 18 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
AFAIK System.IO.Directory 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******@gunnery.org> a écrit dans le message de
news:ek**************@TK2MSFTNGP12.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.Directory.GetFiles(dir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunnery.org

Nov 18 '05 #2

P: n/a
Something like this might work?

Dim files As String() = System.IO.Directory.GetFiles(Server.MapPath(dir),
"*.jpg")

cheers,
mortb
Nov 18 '05 #3

P: n/a
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******@gunnery.org


"Patrice" <no****@nowhere.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
AFAIK System.IO.Directory 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******@gunnery.org> a écrit dans le message de
news:ek**************@TK2MSFTNGP12.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.Directory.GetFiles(dir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunnery.org


Nov 18 '05 #4

P: n/a
> 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******@gunnery.org> wrote in message
news:OO**************@TK2MSFTNGP12.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******@gunnery.org


"Patrice" <no****@nowhere.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
AFAIK System.IO.Directory 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******@gunnery.org> a écrit dans le message de
news:ek**************@TK2MSFTNGP12.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.Directory.GetFiles(dir, "*.jpg")

result = files.Length

thanks

bj daniels

da******@gunnery.org



Nov 18 '05 #5

P: n/a
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*************@TK2MSFTNGP09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Directory.GetFiles(Server.MapPath(dir),
"*.jpg")

cheers,
mortb

Nov 18 '05 #6

P: n/a
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*************@TK2MSFTNGP09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Directory.GetFiles(Server.MapPath(dir),
"*.jpg")

cheers,
mortb

Nov 18 '05 #7

P: n/a
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****************@TK2MSFTNGP12.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*************@TK2MSFTNGP09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Directory.GetFiles(Server.MapPath(dir), "*.jpg")

cheers,
mortb


Nov 18 '05 #8

P: n/a
if there an easy way to make that info available? Is that what a web
service would do?

bj
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.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******@gunnery.org> wrote in message
news:OO**************@TK2MSFTNGP12.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******@gunnery.org


"Patrice" <no****@nowhere.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
AFAIK System.IO.Directory 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******@gunnery.org> a écrit dans le message de
news:ek**************@TK2MSFTNGP12.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.Directory.GetFiles(dir, "*.jpg")
>
> result = files.Length
>
>
>
> thanks
>
>
>
> bj daniels
>
> da******@gunnery.org
>
>
>
>



Nov 18 '05 #9

P: n/a
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******@gunnery.org> wrote in message
news:ut**************@TK2MSFTNGP12.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****************@TK2MSFTNGP12.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*************@TK2MSFTNGP09.phx.gbl...
Something like this might work?

Dim files As String() = System.IO.Directory.GetFiles(Server.MapPath(dir), "*.jpg")

cheers,
mortb



Nov 18 '05 #10

P: n/a
thanks
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:u2**************@TK2MSFTNGP11.phx.gbl...
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******@gunnery.org> wrote in message
news:ut**************@TK2MSFTNGP12.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****************@TK2MSFTNGP12.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*************@TK2MSFTNGP09.phx.gbl...
> Something like this might work?
>
> Dim files As String() =

System.IO.Directory.GetFiles(Server.MapPath(dir),
> "*.jpg")
>
> cheers,
> mortb
>
>



Nov 18 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.