This should be an easy quick question:
I have this code below which I acquired from this forum I believe. It works great but I now need to change it from a local folder on the intranet server to a unc path. This is the code that works:
Now, I know I need to make this change at the top and remove the Server.Mappath portion and change it out to the UNC path as such:
The documents list on the asp page with no problems but the links aren't working properly and I know it has something to do with this part:
What do I need to do here? without editing this part, it's trimming everything except "cuments\" ... so a linked document can't open and the path looks like:
I tried running the original script in the new location with a virtual directory but the script won't see the path via a virtual directory which is why I'm doing it this way now ... unless I missed something ...
Any help? I think i have all my facts in line!)
Thanks!
MojoZig
I have this code below which I acquired from this forum I believe. It works great but I now need to change it from a local folder on the intranet server to a unc path. This is the code that works:
Code:
<!-- List these three folders. -->
<ul>
<% ListFolderContents(Server.MapPath("/Departments/Department_folder")) %>
<!--
% ListFolderContents(Server.MapPath("/dhtml")) %>
% ListFolderContents(Server.MapPath("/js")) %>
-->
</ul>
<% sub ListFolderContents(path)
dim fs, folder, file, item, url
set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)
'Display the target folder and info.
Response.Write("<li><b>" & folder.Name & "</b> - " _
& folder.Files.Count & " files, ")
if folder.SubFolders.Count > 0 then
Response.Write(folder.SubFolders.Count & " directories, ")
end if
Response.Write(Round(folder.Size / 1024) & " KB total." _
& vbCrLf)
Response.Write("<ul>" & vbCrLf)
'Display a list of sub folders.
for each item in folder.SubFolders
ListFolderContents(item.Path)
next
'Display a list of files.
for each item in folder.Files
url = MapURL(item.path)
Response.Write("<li><a href=""" & url & """>" & item.Name & "</a> - " _
& item.Size & " bytes, " _
& "last modified on " & item.DateLastModified & "." _
& "</li>" & vbCrLf)
next
Response.Write("</ul>" & vbCrLf)
Response.Write("</li>" & vbCrLf)
end sub
function MapURL(path)
dim rootPath, url
'Convert a physical file path to a URL for hypertext links.
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
end function %>
Now, I know I need to make this change at the top and remove the Server.Mappath portion and change it out to the UNC path as such:
Code:
<% ListFolderContents(("\\fileserver\Departments\Department_Folder\")) %>
The documents list on the asp page with no problems but the links aren't working properly and I know it has something to do with this part:
Code:
dim rootPath, url
'Convert a physical file path to a URL for hypertext links.
rootPath = Server.MapPath("/")
url = Right(path, Len(path) - Len(rootPath))
MapURL = Replace(url, "\", "/")
What do I need to do here? without editing this part, it's trimming everything except "cuments\" ... so a linked document can't open and the path looks like:
I tried running the original script in the new location with a virtual directory but the script won't see the path via a virtual directory which is why I'm doing it this way now ... unless I missed something ...
Any help? I think i have all my facts in line!)
Thanks!
MojoZig