title: How to create correctly escaped file:// URI in C#?
body: <p>What would be the correct way to create a fully URL-encoded <code>file://</code> URI from a local path, i.e. where all special characters such as blanks etc are escaped?</p>
  
  <p>Given the following input</p>
  
  <pre><code>C:\Data\Input Document.txt
  </code></pre>
  
  <p>I would like to get </p>
  
  <pre><code>file:///C:/Data/Input%20Document.txt
  </code></pre>
  
  <p>I've been using </p>
  
  <pre><code>Uri uri = new Uri(@"C:\Data\Input Document.txt", UriKind.RelativeOrAbsolute); 
  </code></pre>
  
  <p>However, this results in an unescaped URI:</p>
  
  <pre><code>file:///C:/Data/Input Document.txt
  </code></pre>