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 System.IO.File.Copy(...) command fails sometimes unexpectedly while it worked a minute before and works again a minute after... filer is working with the CIFS file system.
in my Log4Net logfiles I see the exception:
System.IO.IOException: The specified network name is no longer available. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) ...
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.
Are there common patterns or .NET classes suitable to do this copy and retry or should I simply use an approach like in the following pseudo-code?
while(!copied && count <5)
{
count++;
try
{
//here copy the file
...
//if no exception copy was ok
copied = true;
}
catch
{
if(count >= 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...
}
}
}