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

Getting directory listings from a client machine

P: n/a
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
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Fri, 20 Aug 2004 02:11:02 -0700, "Carolyn Speakman"
<Ca*************@discussions.microsoft.com> 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


Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.