title: Safely copy files on NAS Filer
body: <p>we have a NetApp NAS filer which from time to time seems to fail, not sure if this depends on network issues, heavy load or the Filer itself; the thing is that the usual <code>System.IO.File.Copy(...)</code> command fails sometimes unexpectedly while it worked a minute before and works again a minute after... filer is working with the CIFS file system.</p>
  
  <p>in my Log4Net logfiles I see the exception:</p>
  
  <blockquote>
    <p>System.IO.IOException: The specified network name is no longer
    available.    at System.IO.__Error.WinIOError(Int32 errorCode, String
    maybeFullPath) ...</p>
  </blockquote>
  
  <p>network team is unsure what happens and why, I am now thinking if I can implement a simple try/retry system to copy the file and retry the copy in case of failure, it could possibly be that System.IO.File.Copy was not designed for CIFS storages but for normal NTFS drives or stable network storage.</p>
  
  <p>Are there common patterns or .NET classes suitable to do this <em>copy and retry</em> or should I simply use an approach like in the following pseudo-code?</p>
  
  <pre><code>while(!copied &amp;&amp; count &lt;5)
  {
    count++;
  
    try
    {
      //here copy the file
      ...
  
      //if no exception copy was ok
      copied = true;
    }
    catch
    {
      if(count &gt;= 5)
      {
        // Log that retry limit has been reached...
      }
      else
      {
        // make thread to wait for some time,
        // waiting time can be in function of count or fixed...
      }
    }
  } 
  </code></pre>