private static void WaitForFileReady( string newFilePath )
{
bool goodOpen = false;
int totalTries = 100;
while ( !goodOpen )
{
try
{
FileStream s = File.OpenRead( newFilePath );
goodOpen = s.Length > 0;
s.Close( );
s.Dispose( );
}
catch ( Exception )
{
if ( totalTries-- == 0 )
throw;
Thread.Sleep( 50 );
}
}
}