title: WebClient DownloadFile - Access denied or could not find part of the path
body: <p>I am trying to set a button so that the user can download a file saved on the server.</p>
  
  <pre><code>protected void btnDownloadHtmlFile_Click(object sender, EventArgs e)
  {
      string path = @"D:\web\mytestwebsite.com\www\temp\test.html";
      if (!File.Exists(path))
      {
          File.Create(path);
      }
  
      TextWriter tw = new StreamWriter(path);
      tw.WriteLine("&lt;head&gt;&lt;/head&gt;&lt;body&gt;test&lt;/body&gt;");
      tw.Close();
  
      WebClient webclient = new WebClient();
      webclient.DownloadFile(@"D:\web\mytestwebsite.com\www\temp\test.html", @"C:\web\test.html");
  }
  </code></pre>
  
  <p>This result in <code>Could not find a part of the path 'C:\web\test.html'.</code>
  Same if I change for</p>
  
  <pre><code> webclient.DownloadFile(new Uri("http://mytestwebsite.com/temp/test.html"), @"C:\web\test.html");
  </code></pre>
  
  <p>If I change for </p>
  
  <pre><code>webclient.DownloadFile(@"D:\web\mytestwebsite.com\www\temp\test.html", "test.html");
  </code></pre>
  
  <p>or</p>
  
  <pre><code>webclient.DownloadFile(new Uri("http://mytestwebsite.com/temp/test.html"), "test.html");
  </code></pre>
  
  <p>I get Access to the path 'C:\Windows\SysWOW64\inetsrv\test.html' is denied.</p>
  
  <p>Finally I went to the folder C:\Windows\SysWOW64\inetsrv to give permissions to NETWORK SERVICE but it says access denied. I am logged as a Admin on the server.</p>
  
  <p>I read a few posts on this but nothing seems to work for or I missed something.</p>
  
  <p>What is right way to use WebcClient.DownloadFile?</p>