I have a problem and I searched hours to find a solution but there was nothing that fixed my error. So I'll coded a button and the button should download a File and place it in a directory via DownloadFile(); But everytime if I try to download the File VS show me this error UnauthorizedAccessException The access of [C:\User...] is denied + System.Net.WebException. Here's my code.
private void button1_Click(object sender, EventArgs e)
{
WebClient Client = new WebClient();
string Download =
"http://zentrixdevelopers.com/downloads/Debug.rar";
string Location =
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
+
@"\Zentrix\Update";
Directory.GetAccessControl(Location);
Client.DownloadFile(Download, Location);
if (!Directory.Exists(Location))
{
DirectoryInfo Folder =
Directory.CreateDirectory(Environment.GetFolderPath
(Environment.SpecialFolder.ApplicationData) + @"\Zentrix");
}
this.Close();
}
Usually it should work but it doesn't.
Aucun commentaire:
Enregistrer un commentaire