public virtual void CopyTo(SmbFile dest)
{
SmbComReadAndX req;
SmbComReadAndXResponse resp;
WriterThread w;
int bsize;
byte[][] b;
if (_share == null || dest._share == null)
{
throw new SmbException("Invalid operation for workgroups or servers");
}
req = new SmbComReadAndX();
resp = new SmbComReadAndXResponse();
Connect0();
dest.Connect0();
ResolveDfs(null);
try
{
if (GetAddress().Equals(dest.GetAddress()) && _canon.RegionMatches(true, 0, dest._canon
, 0, Math.Min(_canon.Length, dest._canon.Length)))
{
throw new SmbException("Source and destination paths overlap.");
}
}
catch (UnknownHostException)
{
}
w = new WriterThread(this);
w.SetDaemon(true);
w.Start();
SmbTransport t1 = Tree.Session.transport;
SmbTransport t2 = dest.Tree.Session.transport;
if (t1.SndBufSize < t2.SndBufSize)
{
t2.SndBufSize = t1.SndBufSize;
}
else
{
t1.SndBufSize = t2.SndBufSize;
}
bsize = Math.Min(t1.RcvBufSize - 70, t1.SndBufSize - 70);
b = new[] { new byte[bsize], new byte[bsize] };
try
{
CopyTo0(dest, b, bsize, w, req, resp);
}
finally
{
w.Write(null, -1, null, 0);
}
}