Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > list of files in a web folder

Reply
Thread Tools

list of files in a web folder

 
 
Amanda H
Guest
Posts: n/a
 
      02-18-2005
I want to create a web page that lists all the files in a folder-
specifically for photos and video, so that I can just dump a video into the
video folder in my website and it shows up on the video list web page.

I've experimented with the FileSystemObject, but this seems to need absolute
path names, and I'm looking for something simpler with relative path names.

Any suggestions?

Thanks, Amanda


 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      02-18-2005
strPath = Request.Querystring("f")

'// If the querystring is blank, set the path to the current dir
If strPath <> "" Then strPath = "./"

Dim objFSO, objFl, objFldr
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFldr = objFSO.GetFolder(Server.MapPath(strPath))
For Each objFl in objFldr.Files
Response.Write objFl.Name & " - " & objFl.Size & "b<br>"
Next
Set objFSO = Nothing
Set objFldr = Nothing
Set objFl = Nothing

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

"Amanda H" <(E-Mail Removed)> wrote in message
news:zBmRd.1097$(E-Mail Removed) m...
> I want to create a web page that lists all the files in a folder-
> specifically for photos and video, so that I can just dump a video into

the
> video folder in my website and it shows up on the video list web page.
>
> I've experimented with the FileSystemObject, but this seems to need

absolute
> path names, and I'm looking for something simpler with relative path

names.
>
> Any suggestions?
>
> Thanks, Amanda
>
>



 
Reply With Quote
 
 
 
 
Phill. W
Guest
Posts: n/a
 
      02-18-2005
"Amanda H" <(E-Mail Removed)> wrote in message
news:zBmRd.1097$(E-Mail Removed) m...
> I want to create a web page that lists all the files in a folder-
> specifically for photos and video, so that I can just dump a video
> into the video folder in my website and it shows up on the video
> list web page.


One really, /really/ simple, if [possibly] dangerous and [definitely]
un-pretty solution :

Allow Directory Browsing in your video folder.

That way, you just type in the URL of the /folder/ and you'll get
a [default] directory listing automatically; no code required.

Alternatively (because you'll get fed up with the limitations of that
solution fairly quickly), yes; the FSO does need full paths, but you
can translate relative ones /into/ full ones, using the Server objects
MapPath() method, as in

If oFSO.FileExists( Server.MapPath( "./videos/abc.def" ) ) Then

HTH,
Phill W.


 
Reply With Quote
 
Veign
Guest
Posts: n/a
 
      02-18-2005
Checking the length of strPath is more efficient (have heard by as much as
25%) than comparing to an empty string....

Like:
If Len(strPath) = 0 Then strPath = "./"

Just a quick FYI

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

"Steven Burn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> strPath = Request.Querystring("f")
>
> '// If the querystring is blank, set the path to the current dir
> If strPath <> "" Then strPath = "./"
>
> Dim objFSO, objFl, objFldr
> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
> Set objFldr = objFSO.GetFolder(Server.MapPath(strPath))
> For Each objFl in objFldr.Files
> Response.Write objFl.Name & " - " & objFl.Size & "b<br>"
> Next
> Set objFSO = Nothing
> Set objFldr = Nothing
> Set objFl = Nothing
>
> --
> Regards
>
> Steven Burn
> Ur I.T. Mate Group
> www.it-mate.co.uk
>
> Keeping it FREE!
>
> "Amanda H" <(E-Mail Removed)> wrote in message
> news:zBmRd.1097$(E-Mail Removed) m...
> > I want to create a web page that lists all the files in a folder-
> > specifically for photos and video, so that I can just dump a video into

> the
> > video folder in my website and it shows up on the video list web page.
> >
> > I've experimented with the FileSystemObject, but this seems to need

> absolute
> > path names, and I'm looking for something simpler with relative path

> names.
> >
> > Any suggestions?
> >
> > Thanks, Amanda
> >
> >

>
>



 
Reply With Quote
 
ljb
Guest
Posts: n/a
 
      02-21-2005

"Amanda H" <(E-Mail Removed)> wrote in message
news:zBmRd.1097$(E-Mail Removed) m...
> I want to create a web page that lists all the files in a folder-
> specifically for photos and video, so that I can just dump a video into

the
> video folder in my website and it shows up on the video list web page.
>
> I've experimented with the FileSystemObject, but this seems to need

absolute
> path names, and I'm looking for something simpler with relative path

names.
>
> Any suggestions?
>
> Thanks, Amanda
>


DirList.ASP will list all the files and allow you to change the sort order.
Find the source code at http://www.romankoch.ch/capslock/standaloners.htm


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to create the folder "new folder: no new files Cindy Stuart Computer Support 5 06-03-2007 07:32 AM
How do you get a list of files from server folder to display on in a list control maglev_now@yahoo.com ASP .Net 4 10-20-2006 12:39 PM
Interesting one : Retrieve a list of files within a web folder John ASP .Net 2 10-22-2004 11:13 PM
List Files in a Web Folder J P Singh ASP General 1 09-05-2003 03:10 PM
Can't copy Outlook Ex files in folder to Windows folder? Paul - xxx Computer Support 2 08-20-2003 03:06 AM



Advertisments