list of files in a web folder

Discussion in 'ASP General' started by Amanda H, Feb 18, 2005.

  1. Amanda H

    Amanda H Guest

    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
     
    Amanda H, Feb 18, 2005
    #1
    1. Advertising

  2. Amanda H

    Steven Burn Guest

    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" <> wrote in message
    news:zBmRd.1097$...
    > 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
    >
    >
     
    Steven Burn, Feb 18, 2005
    #2
    1. Advertising

  3. Amanda H

    Phill. W Guest

    "Amanda H" <> wrote in message
    news:zBmRd.1097$...
    > 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.
     
    Phill. W, Feb 18, 2005
    #3
  4. Amanda H

    Veign Guest

    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" <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:zBmRd.1097$...
    > > 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
    > >
    > >

    >
    >
     
    Veign, Feb 18, 2005
    #4
  5. Amanda H

    ljb Guest

    "Amanda H" <> wrote in message
    news:zBmRd.1097$...
    > 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
     
    ljb, Feb 21, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    3
    Views:
    2,933
    Alvin Bruney
    Oct 16, 2003
  2. John
    Replies:
    2
    Views:
    4,682
    Mythran
    Oct 23, 2004
  3. Replies:
    4
    Views:
    2,144
  4. =?Utf-8?B?a2V2aW4=?=

    exclude obj folder in web install folder

    =?Utf-8?B?a2V2aW4=?=, Aug 20, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    578
    =?Utf-8?B?a2V2aW4=?=
    Aug 20, 2007
  5. Replies:
    7
    Views:
    398
    Gabriel Genellina
    Sep 25, 2007
Loading...

Share This Page