Good morning, I have a web application that I need to access a disk where I must read and write files and this is on another network, from windows server I can connect to this network drive through a user. Now the problem is the following: to connect from the web application I do it through the classNetworkConnection
But when I need to copy some files from the network drive to a server's own drive (I use it to store temporary files) sometimes it works, and sometimes it doesn't (most fail). The message I get as "error" is the following:
Error connecting to remote share result=1219
The specific code where it fails is this:
string usuario = ConfigurationManager.AppSettings["usrConsultaNAS"];
string password = ConfigurationManager.AppSettings["passConsultaNAS"];
NetworkCredential NCredentials = new NetworkCredential(usuario, password);
using (new NetworkConnection(rutaCarpetasNAS, NCredentials))
{
using (FileStream stream = new FileStream(OutFile, FileMode.Create))
{
using (Document doc = new Document())
{
using (PdfCopy pdf = new PdfCopy(doc, stream))
{
doc.Open();
PdfReader reader = null;
PdfImportedPage page = null;
foreach (var file in InFiles)
{
reader = new PdfReader(file);
for (int i = 0; i < reader.NumberOfPages; i++)
{
page = pdf.GetImportedPage(reader, i + 1);
pdf.AddPage(page);
}
pdf.FreeReader(reader);
reader.Close();
}
}
}
}
}
I thank you in advance for your advice and help.
The official Microsoft documentation says this about that error:
Which means that you have exceeded the number of connections allowed by one or more users, in this case I would use a different username and/or increase the number of simultaneous connections to that shared resource.
It really seems that your code has no problem, the issue is with the consumption of shared resources.