private static void DoBulkCopy(SqlConnection connection, Options options) { Console.WriteLine("Begin bulk copy"); var stopwatch = new Stopwatch(); stopwatch.Start(); var rowsCopied = 0L; var dbfRecordCount = 0L; var dbfDataReaderOptions = new DbfDataReaderOptions { SkipDeletedRecords = options.SkipDeletedRecords }; using (var dbfDataReader = new DbfDataReader.DbfDataReader(options.Dbf, dbfDataReaderOptions)) { dbfRecordCount = dbfDataReader.DbfTable.Header.RecordCount; using (var bulkCopy = new SqlBulkCopy(connection)) { bulkCopy.BulkCopyTimeout = options.BulkCopyTimeout; bulkCopy.DestinationTableName = options.Table; try { bulkCopy.WriteToServer(dbfDataReader); rowsCopied = bulkCopy.RowsCopied(); } catch (Exception ex) { Console.WriteLine($"Error importing: dbf file: '{options.Dbf}', exception: {ex.Message}"); } } } stopwatch.Stop(); Console.WriteLine($"Bulk copy completed in {GetElapsedTime(stopwatch)}s"); Console.WriteLine($"Copied {rowsCopied} of {dbfRecordCount} rows"); }