jsvb1977
asked on
How to make PDF file list in directory clickable links
I have created a directory on the c drive of our web server where users on our local network will drop PDF files.
I have written a routine in asp.net [vb] that iterates through the files in that directory and builds a bulleted list with href links based on the file name and path.
Problem is, the href renders the files with links like this:
file:///C:/GrapevinePDFs/g v_1017.pdf
This is not a valid url or clickable link.
How do turn the file path shown above into a clickable link that visitors to the website can click on to view the PDFs?
Here is the code:
I have written a routine in asp.net [vb] that iterates through the files in that directory and builds a bulleted list with href links based on the file name and path.
Problem is, the href renders the files with links like this:
file:///C:/GrapevinePDFs/g
This is not a valid url or clickable link.
How do turn the file path shown above into a clickable link that visitors to the website can click on to view the PDFs?
Here is the code:
Dim strGrapeVineHREF As String
Dim strGrapeVineLink As String
Dim strPath As String = "C:\GrapevinePDFs"
For Each strGrapeVineHREF In System.IO.Directory.GetFiles(strPath, "*.pdf")
strGrapeVineLink = GrapeVineVerboseName(strPath, strGrapeVineHREF)
Dim li As New HtmlGenericControl("li")
li.InnerHtml = "<a href=""" & strGrapeVineHREF & """ title=""View Grapevine Article"" target=""_blank"">" & strGrapeVineLink & "</a>"
bulGrapevineArticles.Controls.Add(li)
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is the entire block of code:
The Virtual Directory was the real solution, though...
The Virtual Directory was the real solution, though...
Dim strGrapeVine As String
Dim strGrapeVineHREF As String
Dim strGrapeVineLink As String
Dim strPath As String = "C:\GrapevinePDFs\"
For Each strGrapeVine In System.IO.Directory.GetFiles(strPath, "*.pdf")
strGrapeVineHREF = strGrapeVine.Replace(strPath, "GrapevinePDFs/")
strGrapeVineLink = GrapeVineVerboseName(strPath, strGrapeVine)
Dim li As New HtmlGenericControl("li")
li.InnerHtml = "<a href=""" & strGrapeVineHREF & """ title=""View Grapevine Article"" target=""_blank"">" & strGrapeVineLink & "</a>"
bulGrapevineArticles.Controls.Add(li)
Next
I did not write the code since I thought you could do it ;)
ASKER
Hainkurt,
I could see how my last post could have been construed as negative, but it was intended to give you praise.
I only posted the code I wrote so the next person might find it useful.
Thanks for everything!
Jason
I could see how my last post could have been construed as negative, but it was intended to give you praise.
I only posted the code I wrote so the next person might find it useful.
Thanks for everything!
Jason
ASKER
Open in new window