...

View Full Version : Physical Path to a file



dew06
06-23-2005, 07:28 PM
HI everyone,:confused:

I am recently working on a company's project that performs basic search through the database and displays the relevant results. As per project requirement the search result should display the relative path of the document that it found. for e.g.

if the user wants to search through the database for "test" .

The asp page uses indexing service and finds through the database any file containing the word "test" once it finds the document, it displays the relative path to the file i.e.
http://intra.test.arb.bon.omb.gov.on.ca/arb_public/ceo/hearing scheduler table(2)-dec4-02.doc

However, I want it to display absolute path to the document.
d:\inetpub\wwwroot\blah...........\dec04-02.doc

How would I make the query page search through the database and display the physical/relative path to each and every search result found.

I am very new to asp ,I would really appreciate any help in this matter.

Thanks

debo602
06-24-2005, 04:01 AM
Cant' you just take the string that is returned in the search and do a find and replace?

PM me if you need the code.

Roelf
06-24-2005, 09:35 AM
Server.MapPath(path) (http://www.devguru.com/Technologies/asp/quickref/server_mappath.html)

dew06
06-27-2005, 04:16 PM
Cant' you just take the string that is returned in the search and do a find and replace?

PM me if you need the code.


hi debo thx for the reply. I will give it a try.I will appreciate if you can send me the code.

dew

dew06
06-27-2005, 04:28 PM
Server.MapPath(path)

HI roelf,

I have tried the above command but I believe this is best suitable when we know the name of the file .However,in my case its a database. So the name of the file is unknown and moreover, the search engine looks at several directories for e.g. d: ,P: , H: and finds the closest match to the search string.
thx newaz ..


dew

miranda
06-27-2005, 07:22 PM
1st declare a variable and put the file name into that like so
myFile = objRS("filename")
Then you can use the server.MapPath() function to find that file on your server like this Server.MapPath(myFile)

So then instead of writing the path as an anchor
<a href="<%=myFile%>"><%=myFile%></a>
use this
<%=Server.MapPath(myFile)%> or
Write as an anchor but use the physical path
<a href="<%=Server.MapPath(myFile)%>"><%=Server.MapPath(myFile)%></a>

debo602
07-28-2005, 04:39 PM
The code would look something like this



strString = http://intra.test.arb.bon.omb.gov.lic/
if Instr(strString, "http") > 0 then
strTest = replace(strString, "http://intra.test.arb.bon.omb.gov.lic/", "c:\test")
response.write strtest
end if


Here is a link the the replace function in the vbscript reference from microsoft.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctreplace.asp

oracleguy
07-28-2005, 05:41 PM
1st declare a variable and put the file name into that like so
myFile = objRS("filename")
Then you can use the server.MapPath() function to find that file on your server like this Server.MapPath(myFile)

Exactly, and technically you don't even need to use a variable, you can pass the recordset value directing into the MapPath function.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum