protected void WaitUntilFileIsReady(System.String fileName) { if (_eventLogger != null) { _eventLogger.LogEvent(string.Format("Waiting for file availability ({0} current size: {1} bytes", fileName, GetFileSize(fileName).ToString(System.Globalization.CultureInfo.InvariantCulture)), EventTypes.Wait); while (!IsFileReady(fileName)) System.Threading.Thread.Sleep(50); _eventLogger.LogEvent(string.Format("The file {0} is available! ({1}) bytes", fileName, GetFileSize(fileName).ToString(System.Globalization.CultureInfo.InvariantCulture)), EventTypes.Available); } } protected static bool IsFileReady(System.String fileName) { // If the file can be opened for exclusive access it means that the file // is no longer locked by another process. try { using (System.IO.FileStream inputStream = System.IO.File.Open(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.None)) { return (inputStream.Length >= 0); } } catch (System.Exception) { return false; } }You can ignore the _eventLogger, as that is something I use to write into Windows Event Logger (and a SQL DB) to track activity.