UnauthorizedAccessException下载文件

时间:2018-05-11 19:50:28

标签: c# windows web

我单击按钮时尝试下载文件,但是抛出UnauthorizedAccessException并拒绝访问C:\User\...

private void button1_Click(object sender, EventArgs e)
{
    WebClient Client = new WebClient();
    string Download = "http://...";
    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();
}

0 个答案:

没有答案