rendered paste bodywhile( totalSent < file.Length )
{
int chunkSize = ( int )Math.Min( ( long )_CopyBuffer.Length, sStream.Length - sStream.Position );
sStream.Read( _CopyBuffer, 0, chunkSize );
dStream.Write( _CopyBuffer, 0, chunkSize );
if( GetFlag( CopyFlags.Scan ) )
badCount += InternalScan( _CopyBuffer );
totalSent += chunkSize;
_CopySize += chunkSize;
sent += chunkSize;
bool reset = false;
if( _ClipBandwidth && start + TimeSpan.FromSeconds( 1.0 ) < DateTime.Now )
{
reset = true;
}
else if( _ClipBandwidth && _MaxBandwidth == 0 )
{
while( _MaxBandwidth == 0 )
{
Thread.Sleep( 500 );
}
reset = true;
}
else if( _ClipBandwidth && sent > _MaxBandwidth )
{
int toSleep = 1000 - ( DateTime.Now.Millisecond - start.Millisecond );
Thread.Sleep( toSleep );
reset = true;
}
if( reset )
{
sent = 0;
start = DateTime.Now;
}
}