Getting directory listings from a client machine

Discussion in 'ASP General' started by Carolyn Speakman, Aug 20, 2004.

  1. Hi,

    I need to get a directory listing from a client machine. The directory will
    be specified by the user and the results will be stored on the server in an
    xml file. I've been trying to use the fillowing code, but I'm not sure if it
    will work or just look for the directory on the server. Any help out there?

    <%
    Dim strPath 'Path of directory to show
    Dim objFSO 'FileSystemObject variable
    Dim objFolder 'Folder variable
    Dim objItem 'Variable used to loop through the folder contents

    ' Relative path to directory:
    strPath = "C:\someDirectory\"

    ' Create our FSO and get a handle on our folder
    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    Set objFolder = objFSO.GetFolder(strPath)
    Set a = objFSO.CreateTextFile("c:\Inetpub\wwwroot\testfile.xml", True)
    a.WriteLine("<?xml version=""1.0"" encoding=""ISO-8859-1""?>" & Chr(13))
    a.WriteLine("<root>")

    For Each objItem In objFolder.Files
    sommat = split(objItem.Name, ".")
    if sommat(ubound(sommat)) = "exe" Then
    Response.Write "<a href=""" & strPath & objItem.Name & """>" _
    & objItem.Name & "</a><br />" & vbCrLf
    a.WriteLine("<program>")
    a.WriteLine("<name>" & objItem.Name & "</name>")
    a.writeLine("<size>" & objItem.Size & "</size>")
    a.WriteLine("<DateCreated>" & objItem.DateCreated & "</DateCreated>")
    a.WriteLine("</program>")
    End If
    Next 'objItem
    a.WriteLine("</root>")
    a.Close
    ' Done! Kill off our object variables.
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objFSO = Nothing
    %>

    Thanks,
    Carolyn
    Carolyn Speakman, Aug 20, 2004
    #1
    1. Advertising

  2. Carolyn Speakman

    Jeff Cochran Guest

    On Fri, 20 Aug 2004 02:11:02 -0700, "Carolyn Speakman"
    <> wrote:

    >I need to get a directory listing from a client machine. The directory will
    >be specified by the user and the results will be stored on the server in an
    >xml file. I've been trying to use the fillowing code, but I'm not sure if it
    >will work or just look for the directory on the server. Any help out there?


    1) If you have tried the code, you will have answered your question.

    2) To do client-side things you need to use client-side coding. ASP
    is server-side.

    3) http://www.aspfaq.com/show.asp?id=2055

    Jeff


    >
    ><%
    >Dim strPath 'Path of directory to show
    >Dim objFSO 'FileSystemObject variable
    >Dim objFolder 'Folder variable
    >Dim objItem 'Variable used to loop through the folder contents
    >
    >' Relative path to directory:
    >strPath = "C:\someDirectory\"
    >
    >' Create our FSO and get a handle on our folder
    >Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    >Set objFolder = objFSO.GetFolder(strPath)
    >Set a = objFSO.CreateTextFile("c:\Inetpub\wwwroot\testfile.xml", True)
    >a.WriteLine("<?xml version=""1.0"" encoding=""ISO-8859-1""?>" & Chr(13))
    >a.WriteLine("<root>")
    >
    >For Each objItem In objFolder.Files
    > sommat = split(objItem.Name, ".")
    > if sommat(ubound(sommat)) = "exe" Then
    > Response.Write "<a href=""" & strPath & objItem.Name & """>" _
    > & objItem.Name & "</a><br />" & vbCrLf
    > a.WriteLine("<program>")
    > a.WriteLine("<name>" & objItem.Name & "</name>")
    > a.writeLine("<size>" & objItem.Size & "</size>")
    > a.WriteLine("<DateCreated>" & objItem.DateCreated & "</DateCreated>")
    > a.WriteLine("</program>")
    > End If
    >Next 'objItem
    >a.WriteLine("</root>")
    >a.Close
    >' Done! Kill off our object variables.
    >Set objItem = Nothing
    >Set objFolder = Nothing
    >Set objFSO = Nothing
    >%>
    >
    >Thanks,
    >Carolyn
    Jeff Cochran, Aug 20, 2004
    #2
    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. Blogger Team

    Free Listings in Blog directory

    Blogger Team, Nov 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    352
    Blogger Team
    Nov 27, 2005
  2. UJ
    Replies:
    2
    Views:
    419
  3. UJ
    Replies:
    2
    Views:
    408
  4. Dan King

    Dynamic Directory Listings

    Dan King, Aug 2, 2004, in forum: ASP General
    Replies:
    2
    Views:
    118
    Dan King
    Aug 2, 2004
  5. simonh
    Replies:
    6
    Views:
    121
    simonh
    Aug 12, 2010
Loading...

Share This Page