Error al descargar desde el sitio web: no se pudo encontrar una parte de la ruta

I am trying to create a quick fix for a problem I am having. All I need to do is download a file from my website to a local computer.

I have a website using ASP.NET and C# and I have added the code below to a button click to download a file:

WebClient webClient = new WebClient(); webClient.DownloadFile("", @"C:\test\myfile.ext");

which produces the error in the title:

Could not find a part of the path 'C:\test\myfile.ext'.

The directory does exist on my computer.

From what I have read this appears to be a permissions issue on the local computer. I have added full permissions on that directory for the SERVICIO DE RED user as I am running Windows 7. I also have a user that is running XP so I believe the user there would be ASPNET.

Needless to say none of this has worked and allowed me to download the file. I'm a little out of my element here so I'm not sure what to do. It could be that I'm on the right track and just missed something obvious, or maybe I'm way off base.

Anyone have some guidance for me?


The more I think about this, I can't help but think there's a better way to do this.

I've downloaded from websites before without ever needing to deal with permissions, so what would be a better simple approach? What am I missing here?


Thanks, I found exactly what I needed from Hari's responses below.

preguntado el 01 de febrero de 12 a las 22:02

You do not have permissions to write to this file, or the file is all ready open and lock. -

The file in question is located in the root directory of the website. -

2 Respuestas

The user running the application pool used by your website needs to be given permissions to read that file. So, goto IIS > app pools > find the one for your website > the one that's under identity.

Respondido 02 Feb 12, 02:02

My site is hosted on Go Daddy and, try as I might, I haven't been able to find an option for configuring application pools. - GRW

how do you expect godaddy to give you permissions to access some file on c: drive? you can only access files in your hosting space. you should be able to read files from outside your website folder, given that they are still inside your hosting folder, and assuming these permissions are set (I'm sure there are admin options to set read/write permissions to folders that you create there, cause I've seen them). - user191966

this WebClient code is running within the app, right? What are you trying to do? download the file from some external site to the disk space controlled by your app, or download a file from your app to your disk, where your browser is running? - user191966

I want to press a button, from the website hosted on Go Daddy, and download a file, from the root directory of the website, to my local computer where the browser is running. The error I get is complaining about the file destination I specify on the local system. - GRW

you have wrong code; what you are looking for is "streaming files to browser [from]"; see,…,… - usuario191966

Check the application pool identity type to make sure you are granting permission to the correct user, see este sitio web para ver más información.

Respondido 02 Feb 12, 02:02

My site is hosted on Go Daddy and, try as I might, I haven't been able to find an option for configuring application pools. - GRW

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.