Read a directory and next making an action.

Discussion in 'ASP General' started by McGrull, Jul 22, 2005.

  1. McGrull

    McGrull Guest

    Sorry for my question, but I'm really a newbie on ASP.

    I need to make a simple page (for IIS 5.0 and up, but even for 2000
    Professional IIS) that read and display the files contained in a
    specified directory and next, clicking on one of them, calling and
    making an action with an another ASP page. For example:

    http://server/list.asp

    Listing Y:\REPOSITORY

    ONE.TXT
    TWO.TXT


    If I clic on ONE.TXT I need to call

    http://server/action.asp?go=Y:\REPOSITORY\ONE.TXT

    Thank you in advance, and sorry for the dumb question.
    McGrull, Jul 22, 2005
    #1
    1. Advertising

  2. McGrull

    Roland Hall Guest

    "McGrull" wrote in message
    news:...
    : Sorry for my question, but I'm really a newbie on ASP.
    :
    : I need to make a simple page (for IIS 5.0 and up, but even for 2000
    : Professional IIS) that read and display the files contained in a
    : specified directory and next, clicking on one of them, calling and
    : making an action with an another ASP page. For example:
    :
    : http://server/list.asp
    :
    : Listing Y:\REPOSITORY
    :
    : ONE.TXT
    : TWO.TXT
    :
    :
    : If I clic on ONE.TXT I need to call
    :
    : http://server/action.asp?go=Y:\REPOSITORY\ONE.TXT

    It's not a dumb question but why would you want to pass the physical path to
    the file?

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jul 22, 2005
    #2
    1. Advertising

  3. McGrull

    Roland Hall Guest

    "Roland Hall" wrote in message news:...
    : "McGrull" wrote in message
    : news:...
    :: Sorry for my question, but I'm really a newbie on ASP.
    ::
    :: I need to make a simple page (for IIS 5.0 and up, but even for 2000
    :: Professional IIS) that read and display the files contained in a
    :: specified directory and next, clicking on one of them, calling and
    :: making an action with an another ASP page. For example:
    ::
    :: http://server/list.asp
    ::
    :: Listing Y:\REPOSITORY
    ::
    :: ONE.TXT
    :: TWO.TXT
    ::
    ::
    :: If I clic on ONE.TXT I need to call
    ::
    :: http://server/action.asp?go=Y:\REPOSITORY\ONE.TXT
    :
    : It's not a dumb question but why would you want to pass the physical path
    to
    : the file?

    Here is a way to do it without passing the file path/name on the URL.
    http://kiddanger.com/lab/geturl6.asp

    There's a link on the page to view the source.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jul 22, 2005
    #3
  4. McGrull

    McGrull Guest

    Thanks for your reply.

    The application, that is third part, need the real path of the file
    with the file for call argument . I try to call only the file, but
    doesn't do the correct stuff.
    McGrull, Jul 22, 2005
    #4
  5. McGrull

    McGrull Guest

    Thank you for all. Google and a bit of luck, help me..

    I discovered that do the stuff i need. I post it for anyone need the
    same..

    <html>
    <head>
    <title></title>
    </head><body>
    <%
    dirtowalk="/dirtoview/"
    Set fs = Server.CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(server.mappath(dirtowalk))
    Set fc = f.Files
    For Each whatever in fc
    response.write "<A HREF=http://server/make.asp?function="
    response.write whatever.name
    response.write ">"
    response.write whatever.name
    response.write "</A><br>"
    Next
    %>
    </body>
    </html>
    McGrull, Jul 22, 2005
    #5
  6. McGrull

    Roland Hall Guest

    "McGrull" wrote in message
    news:...

    : The application, that is third part, need the real path of the file
    : with the file for call argument . I try to call only the file, but
    : doesn't do the correct stuff.

    you already know your virtual path so...

    dim virPath, strPath
    virPath = "/myfiles"
    strPath = Server.MapPath("/myfiles")
    Just prepend it: strPath & "/" & filename.ext


    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jul 22, 2005
    #6
  7. McGrull

    Roland Hall Guest

    "McGrull" wrote in message
    news:...
    : Thank you for all. Google and a bit of luck, help me..
    :
    : I discovered that do the stuff i need. I post it for anyone need the
    : same..
    :
    : <html>
    : <head>
    : <title></title>
    : </head><body>
    : <%
    : dirtowalk="/dirtoview/"
    : Set fs = Server.CreateObject("Scripting.FileSystemObject")
    : Set f = fs.GetFolder(server.mappath(dirtowalk))
    : Set fc = f.Files
    : For Each whatever in fc
    : response.write "<A HREF=http://server/make.asp?function="
    : response.write whatever.name
    : response.write ">"
    : response.write whatever.name
    : response.write "</A><br>"
    : Next
    : %>
    : </body>
    : </html>

    My app is distinctly different as my URL never changes and nobody can use
    the URL to pass a filename.
    Glad you found something you can use.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jul 22, 2005
    #7
  8. McGrull

    McGrull Guest

    Ok, and if are more files, and i want to array the listing in multiple
    pages, linkable to view the page in my interest, how i can do that?
    McGrull, Jul 22, 2005
    #8
  9. McGrull

    Roland Hall Guest

    "McGrull" wrote in message
    news:...
    : Ok, and if are more files, and i want to array the listing in multiple
    : pages, linkable to view the page in my interest, how i can do that?

    If you're wanting to use the array on multiple pages then you could put your
    array in a session variable but copy it to a local variable when you use it.

    ' get files, put into array
    session("arrFiles") = arrFiles

    ' grab array from session when you want to use it.
    dim arrFiles
    arrFiles = session("arrFiles")

    If you had your files in an array and you had 30 and wanted 10 on each page,
    this is one way:

    pages: list1, list2, list3

    dim i, j, arrList1(), arrList2(), arrList3()
    redim arrList1(9) : redim arrList2(9) : redim arrList3(9)
    j = 0
    for i = 0 to ubound(arrFiles) step 3
    arrList1(j) = arrFiles(i)
    arrList2(j) = arrFiles(i + 1)
    arrList3(j) = arrFiles(i + 2)
    j = j + 1
    next
    erase arrList
    if session("assList1") <> "" then
    session("arrList1") = arrList1
    end if
    session("arrList2") = arrList2
    session("arrList3") = arrList3

    ....then on each page:

    list1.asp
    dim arrList, i
    arrList = session("arrList1")
    for i = 0 to ubound(arrList)
    Response.Write "<a href=""" & arrList & """>" & arrList & "</a><br />"
    next

    list2.asp
    ....
    list3.asp
    ....

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
    Roland Hall, Jul 22, 2005
    #9
    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. Joe Bloggs
    Replies:
    1
    Views:
    704
    Sudsy
    Aug 3, 2003
  2. rjweytens
    Replies:
    6
    Views:
    16,031
    rjweytens
    Jun 25, 2004
  3. Deniz Bahar
    Replies:
    2
    Views:
    443
    Andrey Tarasevich
    Mar 9, 2005
  4. =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki

    Reading of file by next of map file and by next of file descriptor.

    =?ISO-8859-2?Q?Miros=B3aw?= Makowiecki, Jul 10, 2007, in forum: C++
    Replies:
    1
    Views:
    768
    Alf P. Steinbach
    Jul 10, 2007
  5. Tad McClellan
    Replies:
    3
    Views:
    126
    Edward Wijaya
    May 13, 2004
Loading...

Share This Page