C
Carolyn Speakman
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
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