JDL129
asked on
Maximum number of files open in C#
Hey guys!!
We have an application that downloads PDF's and xml files from the clouds, opens them, prints them, but apparently is unable to close them. I need someone to help me with C# code to tell me how to programmatically close these files after they are printed.
Thanks!!
Jerry
We have an application that downloads PDF's and xml files from the clouds, opens them, prints them, but apparently is unable to close them. I need someone to help me with C# code to tell me how to programmatically close these files after they are printed.
Thanks!!
Jerry
Can you provide some source code? Like, how are they being opened and printed or what source code have you attempted to close the files?
If you are simply using a FileStream you can try this after the printing operation completes, assuming your FileStream object is called "fileStream", you can simply call the close() method on the object like so:
fileStream.Close();
ASKER
Element1910!!! Thanks for the post!!
This is some of the code:
writeLog("Get SentTime.");
ft = iTextSharp.text.FontFactor y.GetFont( iTextSharp .text.Font Factory.HE LVETICA, 8, iTextSharp.text.Font.BOLD) ;
string strMsgSent = "";
pdfDocPatient = pdfDoc.GetElementsByTagNam e("SentTim e");
if (pdfDocPatient.Count > 0)
{
strMsgSent = "\r\nSent:" + InitVar.getNullString(emtN um - 12) + pdfDocPatient[0].InnerText ;
}
pdfDocPatient = pdfDoc.GetElementsByTagNam e("Message ID");
if (pdfDocPatient.Count > 0)
{
strMsgSent = strMsgSent + " Sender Message Id:" + pdfDocPatient[0].InnerText ;
}
writeLog("Get StoreName.");
pdfDocument.Add(new iTextSharp.text.Paragraph( strMsgSent , ft));
pdfDocPatient = pdfDoc.GetElementsByTagNam e("StoreNa me");
if (pdfDocPatient.Count > 0)
{
pdfDocument.Add(new iTextSharp.text.Paragraph( "To:" + InitVar.getNullString(emtN um - 9) + pdfDocPatient[0].InnerText , ft));
}
pdfDocPatient = pdfDoc.GetElementsByTagNam e("Pharmac y");
if (pdfDocPatient.Count > 0)
{
pdfDocument.Add(new iTextSharp.text.Paragraph( InitVar.ge tNullStrin g(emtNum - 4) + pdfDocPatient[0]["Address" ]["Address Line1"].In nerText, ft));
pdfDocument.Add(new iTextSharp.text.Paragraph( InitVar.ge tNullStrin g(emtNum - 4) + pdfDocPatient[0]["Address" ]["City"]. InnerText + " " + pdfDocPatient[0]["Address" ]["State"] .InnerText , ft));
pdfDocument.Add(new iTextSharp.text.Paragraph( InitVar.ge tNullStrin g(emtNum - 4) + pdfDocPatient[0]["Address" ]["ZipCode "].InnerTe xt, ft));
}
writeLog("Get Pharmacy.");
XmlNodeList pdfDocNodeList = pdfDoc.GetElementsByTagNam e("Pharmac y");
if (pdfDocNodeList.Count > 0)
{
foreach (XmlNode node in pdfDocNodeList[0])
{
if (countNub > 0)
{
}
countNub++;
}
}
pdfDocument.Close();
if (chkPrint.Checked == true && txtPrinter.Text.Trim() != string.Empty)
{
PrintDoc(pdfName);
pdfDocument = null;
Any ideas?
Thanks again,
Jerry
This is some of the code:
writeLog("Get SentTime.");
ft = iTextSharp.text.FontFactor
string strMsgSent = "";
pdfDocPatient = pdfDoc.GetElementsByTagNam
if (pdfDocPatient.Count > 0)
{
strMsgSent = "\r\nSent:" + InitVar.getNullString(emtN
}
pdfDocPatient = pdfDoc.GetElementsByTagNam
if (pdfDocPatient.Count > 0)
{
strMsgSent = strMsgSent + " Sender Message Id:" + pdfDocPatient[0].InnerText
}
writeLog("Get StoreName.");
pdfDocument.Add(new iTextSharp.text.Paragraph(
pdfDocPatient = pdfDoc.GetElementsByTagNam
if (pdfDocPatient.Count > 0)
{
pdfDocument.Add(new iTextSharp.text.Paragraph(
}
pdfDocPatient = pdfDoc.GetElementsByTagNam
if (pdfDocPatient.Count > 0)
{
pdfDocument.Add(new iTextSharp.text.Paragraph(
pdfDocument.Add(new iTextSharp.text.Paragraph(
pdfDocument.Add(new iTextSharp.text.Paragraph(
}
writeLog("Get Pharmacy.");
XmlNodeList pdfDocNodeList = pdfDoc.GetElementsByTagNam
if (pdfDocNodeList.Count > 0)
{
foreach (XmlNode node in pdfDocNodeList[0])
{
if (countNub > 0)
{
}
countNub++;
}
}
pdfDocument.Close();
if (chkPrint.Checked == true && txtPrinter.Text.Trim() != string.Empty)
{
PrintDoc(pdfName);
pdfDocument = null;
Any ideas?
Thanks again,
Jerry
From work I've done with PDF documents the Adobe process didn't always stop after a close, so that could be the reason if you check TaskManager. I tried to dispose of the calls to Adobe but in the end I had to do a search for all running processes and kill Adobe.
ASKER
angus_young_acdc!!!! Thanks for the post!!!
Could you please post some code here as to how to do that? You would be my hero!!!
Thanks,
Jerry
Could you please post some code here as to how to do that? You would be my hero!!!
Thanks,
Jerry
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You're a life saver!!!!!!!
Thanks again,
Jerry
Thanks again,
Jerry