title: Could not find a part of the path?
body: <p>I have the following code : </p>
  
  <pre><code>fileinfo = new FileInfo(filePathAndName);
  
  if (!fileinfo.Exists)
  {
      using (xmlWriter = new XmlTextWriter(filePathAndName, System.Text.Encoding.UTF8))
      {
          xmlWriter.Formatting = Formatting.Indented;
          xmlWriter.WriteStartDocument();
          xmlWriter.WriteStartElement("root");
          xmlWriter.WriteStartElement("objects");
          xmlWriter.WriteEndElement();
          xmlWriter.WriteEndElement();
          xmlWriter.WriteEndDocument();
          xmlWriter.Close();
      }
  }
  </code></pre>
  
  <p>The filePathAndName will be <code>C:/MyApp%205/Produkter/MyApp%20Utveckling/Host/Orbit.Host.Dev/bin/ExceptionLog.xml.</code></p>
  
  <p>The folder does exists but the file does not. XmlTextWriter should in this case create the file but instead it throws <code>Could not find part of the path</code>.</p>
  
  <p>It's probably something very obvious I have forgotten here, please help.</p>
  
  <p>Edit : This is how the path really looks like : </p>
  
  <pre><code>C:\MyApp 5\Produkter\MyApp Utveckling\Host\Orbit.Host.Dev\Bin
  </code></pre>
  
  <p>And this is how the URL that is used in the code is generated : </p>
  
  <pre><code> (new System.Uri(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase) + "\\ExceptionLog.xml")).AbsolutePath
  </code></pre>