Reputation: 9081
I am beginner in the download files and directories with c# using Web.Net.WebClient
.
I tried this snippet to download a file:
Upload.Models.FichierModels fichier = new FichierModels();
WebClient client = new WebClient();
try
{
client.DownloadFile(new Uri(fichier.GetFichierUrlById(_id)), "fichier");
}
catch { }
but I got this exception:
Access to the path 'C: \ \ Program Files (x86) \ \ IIS Express \ \ file' is denied
What is the cause of this exception? How can I fix my code?
Upvotes: 2
Views: 942
Reputation: 9064
You will have to find out from the application pool for the website what is the identity it is running under.
By default this is Application Pool Identity.
And then you will have to grant that the correct permissions.
Like Follows:
SOLUTION
Start > Administrative Tools > Internet Information Services (IIS) Manager
Expand the machine node > expand Sites
Locate GFI MailArchiver virtual directory
Right-click GFI MailArchiver virtual directory > Edit Permissions...
select Security tab
Add Domain Admins and Domain Users with Full Control Permissions
Referance:
Hope Its Helpful.
Upvotes: 1