ncozzolino
09-24-2004, 05:30 PM
I have a list of all my folders in a directory. I can see the root directory and can access first sub directory fine but when I try to go any deep things don't work.
I have this line of code that passes the folder name.
Response.Write "<TR><TD align=left>" & "<img src=http://ftpserver/drintranet/images/folder.jpg><a href='" & "http://ftpserver/drintranet/drforms/form.asp?method=get&strFolderPath=" & objfolder.Name & "'>" & objfolder.Name & "</a>" & "<br>"
I've gotten the page to re-iterate back through itself to display another folders contents. This is the line of code I've been trying to concatenate for the subfolders. strKeepPath holds objfolder.Name. When I use this it returns http://servername/forms/foldername/foldername. I understand why it is doing this, I'm trying to figure how to continually onto the original path without duplicating the variable within the path.
strPath = Left(strPhysicalPath, InStrRev(strPhysicalPath, "\")) & Right(strPath, InStrRev(strPath, "'strKeepPath'")) & strKeepPath & "\"
If I do this. I can get to the root folder but no where else.
strPath = Left(strPhysicalPath, InStrRev(strPhysicalPath, "\")) & Right(strPath, InStrRev(strPath, "'strKeepPath'"))
Here is all my code. Thanks!
<%
Dim strPathInfo, strPhysicalPath
Dim rootFolder
Dim objFSO, objFile, objFileItem, objFolder, objFolderContents
Dim subFolders
Dim filSize
Dim fldSize
strKeepPath = Request.QueryString("strFolderPath")
strHoldPath = strKeepPath
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)
strPath = Left(strPhysicalPath, InStrRev(strPhysicalPath, "\")) & Right(strPath, InStrRev(strPath, "'strKeepPath'")) & "\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set rootFolder = objFSO.GetFolder(strPath)
Set subFolders = rootFolder.SubFolders
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
response.write strPath & Right(strPath, InStrRev(strPath, "\"))
%>
<font size="7">DR Group Forms</font>
<p><BR>
<BR>
<TABLE cellpadding=5>
</p>
<TR align=center bgcolor="c8c8c8">
<TH align=left><u>Name</u></TH>
<TH><u>Type</u></TH>
<TH><u>Size</u></TH>
<TH><u>Last Modified</u></TH>
</TR>
<%
If objfolder.Size/1000 < 10000 Then
filSize = "MB"
Else
filSize = "KB"
End If
For Each objfolder in subFolders
Response.Write "<TR><TD align=left>" & "<img src=http://ftpserver/drintranet/images/folder.jpg><a href='" & "http://ftpserver/drintranet/drforms/form.asp?method=get&strFolderPath=" & objfolder.Name & "'>" & objfolder.Name & "</a>" & "<br>"
Response.Write "</TD><TD align=center>" & objfolder.Type & "<br>"
Response.Write "</TD><TD align=right>" & objfolder.Size/1000 & filSize & "<br>"
Response.Write "</TD><TD align=right>" & objfolder.DateLastModified & "<BR>"
'Response.Write "</TD><TD align=left>Attributes: " & objfolder.Attributes & "<br>"
'Response.Write "</TD><TD align=right>ShortName: " & objfolder.ShortName & "<br>"
Response.Write "</TD></TR>"
Next
For Each objFileItem in objFolderContents
Response.Write "<TR><TD align=left>"
Response.Write "<img src=http://ftpserver/drintranet/images/document.gif><a href='" & strPath & objFileItem.Name & "'>" & objFileItem.Name & "</a>"
Response.Write "</TD><TD align=right> "
Response.Write objFileItem.Type
Response.Write "</TD><TD align=right> "
Response.Write objFileItem.Size/1000 & "KB"
Response.Write "</TD><TD align=right>"
Response.Write objFileItem.DateLastModified
Response.Write "</TD></TR>"
Next
'AvgScore = int(AvgScore * 100) /100
%>
I have this line of code that passes the folder name.
Response.Write "<TR><TD align=left>" & "<img src=http://ftpserver/drintranet/images/folder.jpg><a href='" & "http://ftpserver/drintranet/drforms/form.asp?method=get&strFolderPath=" & objfolder.Name & "'>" & objfolder.Name & "</a>" & "<br>"
I've gotten the page to re-iterate back through itself to display another folders contents. This is the line of code I've been trying to concatenate for the subfolders. strKeepPath holds objfolder.Name. When I use this it returns http://servername/forms/foldername/foldername. I understand why it is doing this, I'm trying to figure how to continually onto the original path without duplicating the variable within the path.
strPath = Left(strPhysicalPath, InStrRev(strPhysicalPath, "\")) & Right(strPath, InStrRev(strPath, "'strKeepPath'")) & strKeepPath & "\"
If I do this. I can get to the root folder but no where else.
strPath = Left(strPhysicalPath, InStrRev(strPhysicalPath, "\")) & Right(strPath, InStrRev(strPath, "'strKeepPath'"))
Here is all my code. Thanks!
<%
Dim strPathInfo, strPhysicalPath
Dim rootFolder
Dim objFSO, objFile, objFileItem, objFolder, objFolderContents
Dim subFolders
Dim filSize
Dim fldSize
strKeepPath = Request.QueryString("strFolderPath")
strHoldPath = strKeepPath
strPathInfo = Request.ServerVariables("PATH_INFO")
strPhysicalPath = Server.MapPath(strPathInfo)
strPath = Left(strPhysicalPath, InStrRev(strPhysicalPath, "\")) & Right(strPath, InStrRev(strPath, "'strKeepPath'")) & "\"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set rootFolder = objFSO.GetFolder(strPath)
Set subFolders = rootFolder.SubFolders
Set objFile = objFSO.GetFile(strPhysicalPath)
Set objFolder = objFile.ParentFolder
Set objFolderContents = objFolder.Files
response.write strPath & Right(strPath, InStrRev(strPath, "\"))
%>
<font size="7">DR Group Forms</font>
<p><BR>
<BR>
<TABLE cellpadding=5>
</p>
<TR align=center bgcolor="c8c8c8">
<TH align=left><u>Name</u></TH>
<TH><u>Type</u></TH>
<TH><u>Size</u></TH>
<TH><u>Last Modified</u></TH>
</TR>
<%
If objfolder.Size/1000 < 10000 Then
filSize = "MB"
Else
filSize = "KB"
End If
For Each objfolder in subFolders
Response.Write "<TR><TD align=left>" & "<img src=http://ftpserver/drintranet/images/folder.jpg><a href='" & "http://ftpserver/drintranet/drforms/form.asp?method=get&strFolderPath=" & objfolder.Name & "'>" & objfolder.Name & "</a>" & "<br>"
Response.Write "</TD><TD align=center>" & objfolder.Type & "<br>"
Response.Write "</TD><TD align=right>" & objfolder.Size/1000 & filSize & "<br>"
Response.Write "</TD><TD align=right>" & objfolder.DateLastModified & "<BR>"
'Response.Write "</TD><TD align=left>Attributes: " & objfolder.Attributes & "<br>"
'Response.Write "</TD><TD align=right>ShortName: " & objfolder.ShortName & "<br>"
Response.Write "</TD></TR>"
Next
For Each objFileItem in objFolderContents
Response.Write "<TR><TD align=left>"
Response.Write "<img src=http://ftpserver/drintranet/images/document.gif><a href='" & strPath & objFileItem.Name & "'>" & objFileItem.Name & "</a>"
Response.Write "</TD><TD align=right> "
Response.Write objFileItem.Type
Response.Write "</TD><TD align=right> "
Response.Write objFileItem.Size/1000 & "KB"
Response.Write "</TD><TD align=right>"
Response.Write objFileItem.DateLastModified
Response.Write "</TD></TR>"
Next
'AvgScore = int(AvgScore * 100) /100
%>