Re: Access Denied
- From: rn5a@xxxxxxxxxxxxxx
- Date: 11 Jan 2007 16:46:16 -0800
Bruce, I guess you have got it wrong. What I am trying to do is allow
users to DOWNLOAD a file from a directory that resides on the server so
that they can SAVE that file on their local machine.
bruce barker wrote:
webclient is used to read a file from the web. you are asking it to
download from a file path which is not normally allowed.
i believe you are trying to read the file and send to the browser, which
would be:
Response.TransmitFile(
Path.Combine(
Server.MapPath("Folder1\MyDir")
,strFileName));
you will still need to set the content-type header.
-- bruce (sqlwork.com)
rn5a@xxxxxxxxxxxxxx wrote:
I have a ASPX page which has a ListBox & a Button. The ListBox lists
all the files & directories existing in a directory on the server. I
want to give users the option to download files from the server.
When a user selects a file from the ListBox & clicks the button to
download the selected file, I am getting the following error:
Access to the path 'c:\inetpub\wwwroot\Folder1\MyDir' is denied.
The directories & files that the ListBox lists reside in the 'MyDir'
directory. This is the OnClick event function of the button:
<%@ Import Namespace="System.Net" %>
Sub DwnldFile(obj As Object, ea As EventArgs)
Dim strFileName As String
Dim wClient As New WebClient
strFileName = Request.Form("lstFD")
wClient.DownloadFile(Server.MapPath("Folder1\MyDir"), strFileName)
End Sub
I have gone through a no. of posts to resolve this issue but haven't
had any luck so far.
Can someone please tell me where I could be going wrong?
.
- Follow-Ups:
- Re: Access Denied
- From: Mark Fitzpatrick
- Re: Access Denied
- References:
- Access Denied
- From: rn5a
- Re: Access Denied
- From: bruce barker
- Access Denied
- Prev by Date: Client (/Script) Callback fails on certain IE6 installlation
- Next by Date: Re: Authorization based on roles or directory access?
- Previous by thread: Re: Access Denied
- Next by thread: Re: Access Denied
- Index(es):