title: how to resolve relative path in c#
body: <p>i have a function which combine path.
  Example</p>
  
  <p>My application is located in <code>D:\toto\titi\tata\myapplication.exe</code></p>
  
  <p>And I create a windows form application(c#) which solve the relative path  based on the path of my application (<code>D:\toto\titi\tata\myapplication.exe</code>).</p>
  
  <p>I want to this this :</p>
  
  <p>1)Path to resolve is  <code>test.txt  =&gt; D:\toto\titi\tata\test.txt</code></p>
  
  <p>2)Path to resolve is  <code>.\..\..\test\test.txt  =&gt; D:\toto\test\test.txt</code></p>
  
  <p>3)Path to resolve is  <code>.\..\test\test.txt  =&gt; D:\toto\titi\test\test.txt</code></p>
  
  <p>4)Path to resolve is  <code>.\..\..\..\test\test.txt  =&gt; D:\test\test.txt</code></p>
  
  <p>5)Path to resolve is  <code>.\..\..\..\..\test\test.txt  =&gt; The path doesn't exist</code></p>
  
  <p>6)Path to resolve is  <code>\\server\share\folder\test =&gt; get the corresponding path in the server</code>.</p>
  
  <p>I use this method </p>
  
  <pre><code>private void btnSearchFile_Click(object sender, EventArgs e)
  {
      // Open an existing file, or create a new one.
      FileInfo fi = new FileInfo(@"D:\toto\titi\tata\myapplication.exe");
  
      // Determine the full path of the file just created or opening.
      string fpath = fi.DirectoryName;
  
      // First case.
      string relPath1 = txtBoxSearchFile.Text;
      FileInfo fiCase1 = new FileInfo(Path.Combine(fi.DirectoryName, relPath1.TrimStart('\\')));
  
      //Full path
      string fullpathCase1 = fiCase1.FullName;
  
      txtBoxFoundFile.Text = fullpathCase1;
  }
  </code></pre>
  
  <p>but i doesn't solve point 1);point 5) and point 6)</p>
  
  <p>Can you help me</p>