private string AttemptRead(string path)
{
var numTries = 0;
string result = null;
// This is lame but apparently the only consistent way to wait for a lock on a file
while (numTries < 10)
{
try
{
result = File.ReadAllText(path);
numTries = 11;
}
catch (IOException)
{
Thread.Sleep(300);
numTries++;
}
}
return result;
}
}