title: Sharing directory in network c#
body: <p>I have to copy files from a distant directory in the same network. i succed to access to this directory :</p>
  
  <pre><code>   string[] parts = Regex.Split(@directory_path, @"\\");
                 // l'emplacement de repertoire \\nom de la machine\nomde repertoire
               string distant_directory =  @"\\"+Environment.MachineName+ @"\" + parts[parts.Length - 2];
              string local_directory = @"StlDirectory";
              CopyDir(distant_directory, local_directory);
  </code></pre>
  
  <p>the function of copy is the following :</p>
  
  <pre><code> public  void CopyDir(string sourceDir, string destDir)
          {
              DirectoryInfo dir = new DirectoryInfo(sourceDir);
              if (dir.Exists)
              {
                  string realDestDir;
                  if (dir.Root.Name != dir.Name)
                  {
                      realDestDir = System.IO.Path.Combine(destDir, dir.Name);
                      if (!Directory.Exists(realDestDir))
                          Directory.CreateDirectory(realDestDir);
                  }
                  else realDestDir = destDir;
                  foreach (string d in Directory.GetDirectories(sourceDir))
                      CopyDir(d, realDestDir);
                  foreach (string file in Directory.GetFiles(sourceDir))
                  {
  
                      string fileNameDest = System.IO.Path.Combine(realDestDir, System.IO.Path.GetFileName(file));
                      if (!File.Exists(fileNameDest))
  
                      File.Copy(file, fileNameDest, true);
                  }
              }
          }
  </code></pre>
  
  <p>But an error appears <code>Could not find a part of the path 'StlDirectory \ BM529234-CRL39-LF.stl'</code> .</p>
  
  <ol>
  <li>Why this error appears?</li>
  <li>How can i fix it?</li>
  </ol>