title: C# WebClient download file to absolute path
body: <p>I'm working with ASP.NET Core and try to download a file to an absolute path.</p>
  <p>But the problem I have is that the file always gets downloaded to the project directory and the filename itself gets the name of the whole path.</p>
  <p>My Code:</p>
  <pre><code>string path = @&quot;C:\Users\User\file.txt&quot;;
  string url = &quot;https://example.com/file.txt&quot;;
  using (var client = new WebClient())
  {
      client.DownloadFile(url, path);
  }
  </code></pre>
  <p>With this code the file gets then saved in the project folder with the file name <code>C:\Users\User\file.txt</code>, instead of being saved in the directory <code>C:\Users\User</code> with the file name <code>file.txt</code>.</p>
  <p>The backslashes and the colon get replaced with some special characters, because they are not allowed in the filename.</p>