...

View Full Version : Virtual vs Physical



sylvielaps
04-17-2006, 10:11 PM
Hi guys:

I'm so close to finishing this, but I keep on getting the error to use virtual address instead of physical. However I'm getting the actual path from a form query. So the Code is:
<%
Dim strPath
Dim objFSO
Dim objFolder
Dim objItem
Dim rstFiles
Const adVarChar = 200
Const adInteger = 3
Const adDate = 7

strPath = Request.QueryString("path")
Response.Write(path)

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(Server.MapPath(strPath))
%>

So how would I fixed this problem?
Thanks.

degsy
04-18-2006, 04:33 PM
Server.Mappath is expecting a path from the webroot

e.g.


Server.Mappath("\")
Server.Mappath("\data\file.asp")
Server.Mappath("data\file.asp")


What format is your variable in?

sylvielaps
04-18-2006, 05:04 PM
Essentially, the variable is a path that the user can enter based on searching files from a computer. I realize that you wouldn't normally do this, I'm taking a course and this is the required assignment. So basically the user enters the path they would like to see and then the files will show up in an HTML table. Does that help you?

Thanks for your input,

degsy
04-18-2006, 05:21 PM
Response.Write the path. What is it?

sylvielaps
04-19-2006, 01:08 AM
Sorry, I'm not sure what you mean, but this is the remaining code after that first one.

<html>
<head>
<title>Show Directory</title>
</head>
<body>
Contents of <strong><%= strPath %></strong><br />

<br />

<table border="5" bordercolor="green" cellspacing="0" cellpadding="2">
<tr bgcolor="#006600">
<td><font color="#FFFFFF"><b>File Name:</b></font></td>
<td><font color="#FFFFFF"><b>File Size (bytes):</b></font></td>
<td><font color="#FFFFFF"><b>Date Created:</b></font></td>
<td><font color="#FFFFFF"><b>File Type:</b></font></td>
</tr>
<%
For Each objItem In objFolder.SubFolders
If InStr(1, objItem, "_vti", 1) = 0 Then
%>
<tr bgcolor="#CCFFCC">
<td align="left" ><a href="<%= strPath & objItem.Name %>"><%= objItem.Name %></a>&nbsp;</td>
<td align="right"><%= objItem.DateCreated %>&nbsp;</td>
<td align="left" ><%= objItem.DateLastModified %>&nbsp;</td>
<td align="left" ><%= objItem.DateLastAccessed %>&nbsp;</td>
</tr>
<%
End If
Next
Set rstFiles = Server.CreateObject("ADODB.Recordset")
rstFiles.Fields.Append "name", adVarChar, 255
rstFiles.Fields.Append "date", adInteger
rstFiles.Fields.Append "mod", adDate
rstFiles.Fields.Append "access", adVarChar, 255
rstFiles.Open

For Each objItem In objFolder.Files
rstFiles.AddNew
rstFiles.Fields("name").Value = objItem.Name
rstFiles.Fields("date").Value = objItem.DateCreated
rstFiles.Fields("mod").Value = objItem.DateLastModified
rstFiles.Fields("access").Value = objItem.DateLastAccessed
Next

Set objItem = Nothing
Set objFolder = Nothing
Set objFSO = Nothing

rstFiles.Sort = "size ASC, date DESC"

rstFiles.MoveFirst

Do While Not rstFiles.EOF
%>
<tr bgcolor="#CCFFCC">
<td align="left" ><a href="<%= strPath & rstFiles.Fields("name").Value %>"><%= rstFiles.Fields("name").Value %></a>&nbsp;</td>
<td align="right"><%= rstFiles.Fields("size").Value %>&nbsp;</td>
<td align="left" ><%= rstFiles.Fields("date").Value %>&nbsp;</td>
<td align="left" ><%= rstFiles.Fields("type").Value %>&nbsp;</td>
</tr>
<%
rstFiles.MoveNext
Loop

rstFiles.Close
Set rstFiles = Nothing
%>
</table>
</body>
</html>

chud_wallice
04-19-2006, 03:49 PM
i think what degsy is asking is:

in your code just after you assign a value to
strPath

you write it to the output.



response.write strPath


what does is say?
is it what you expect?
is it really a valid path?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum