I'm trying to copy several files to a shared folder (Aprox 20), but each file simultaneously on different threads.
I'm using a Code like this to copy the file
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsIdentity identity = new WindowsIdentity(username, password);
WindowsImpersonationContext context = identity.Impersonate();
try
{
File.Copy(@"c:\temp\MyFile.txt", @"\\server\folder\Myfile.txt", true);
}
catch
{
context.Undo();
}
but some of the files don't get copied and the error that I get is the following:
"No se pueden realizar más conexiones a este equipo remoto en este momento, ya que hay más de las que puede aceptar"
Translated would be something like
"No more connections can be made to this remote computer at this time, as there are more connections that it can accept"
Is there another way to copy the file to the shared folder or to explicity close the connection?
Try copying the files over the same thread. I'm sure having one thread per connection is allowing the server to hit its limit.