Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

Downloading Files from Folder with Hyperlink

7:55 pm on Jun 18, 2011 (gmt 0)

New User

5+ Year Member

joined:Dec 4, 2009
posts: 17
votes: 0

I am downloading pdf files directly from the uploads folder in the root of the website, using the basic code below for test.
This displays the files as an hyperlink as required allowing selected files to opened. However, when clicked to open the file
itís not found; Error 404 Requested URL: /Newsletter1.pdf. The uploads folder path seems to be missing.Is there a way to download the complete path in order that they may be opened?

<script type="text/vbscript" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
Dim dirInfo as New DirectoryInfo(Server.MapPath("~/uploads/"))
articleList.DataSource = dirInfo.GetFiles("*")
End Sub

<form id="form1" runat="server">
<asp:GridView runat="server" id="articleList"
HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">
<asp:HyperLinkField DataNavigateUrlFields="name" DataTextField="name"
HeaderText="Newsletter Files"/>
2:04 pm on June 20, 2011 (gmt 0)


WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
votes: 3

try adding DataNavigateUrlFormatString

see below
<asp:HyperLinkField DataNavigateUrlFields="name" DataNavigateUrlFormatString="~/uploads/{0}" DataTextField="name"
HeaderText="Newsletter Files"/>
3:54 pm on June 20, 2011 (gmt 0)

New User

5+ Year Member

joined:Dec 4, 2009
posts: 17
votes: 0

Many thanks for you response. Your solution works fine, all files can now be downloaded.