title: Connecting / Copying from network drive
body: <p>Not totally sure how to approach this. I've researched a bit but I've come up short. Trying to connect to the network drives at work and copy out the newest folder (updates to a project) For me, the dir starts as \ but when i add that to a string variable it won't connect and won't display when i attempt to check it. is there a process to this?</p>
  
  <p>This is what i have. And it has to be wrong in someway.</p>
  
  <pre><code>string updir = @"\\NetworkDrive\updates\xxxxx";
  
  public void CopyAll(DirectoryInfo source, DirectoryInfo target)
      {
  
          try
          {
              //check if the target directory exists
              if (Directory.Exists(target.FullName) == false)
              {
                  Directory.CreateDirectory(target.FullName);
              }
  
              //copy all the files into the new directory
  
              foreach (FileInfo fi in source.GetFiles())
              {
                  fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
              }
  
  
              //copy all the sub directories using recursion
  
              foreach (DirectoryInfo diSourceDir in source.GetDirectories())
              {
                  DirectoryInfo nextTargetDir = target.CreateSubdirectory(diSourceDir.Name);
                  CopyAll(diSourceDir, nextTargetDir);
              }
              //success here
              copyall = true;    
          }
  
          catch (IOException ie)
          {
              //handle it here
              copyall = false;
          }
      }
  </code></pre>
  
  <p>i've been using that to copy. And it works well. </p>
  
  <pre><code>DateTime lastHigh = new DateTime(1900, 1, 1);
          string highDir;
          foreach (string subdir in Directory.GetDirectories(updir))
          {
              DirectoryInfo fi1 = new DirectoryInfo(subdir);
              DateTime created = fi1.LastWriteTime;
  
              if (created &gt; lastHigh)
              {
                  highDir = subdir;
                  lastHigh = created;
              }
          }
  </code></pre>
  
  <p>and that to find the newest folder.</p>