public static void CopyUnlocked(string from, string to)
{
int attempts = FileIORetryCount;
do
{
try
{
using (var ifs = new FileStream(from, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (var ofs = new FileStream(to, FileMode.OpenOrCreate, FileAccess.Write))
{
ifs.CopyTo(ofs);
return;
}
}
}
catch (IOException)
{
attempts--;
if (attempts == 0) throw;
System.Threading.Thread.Sleep(FileIORetrySleep);
}
} while (true);
}