My company is very close to deploying your software to do email invoicing for our customer, but we've hit one final snag. When attempting to attach a PDF file to a .NET MailMessage, we get an error that indicates that the file is still locked.
The sequence of steps is:
/** Document and Message already created */
string filePath = @"gohere.pdf";
document.Draw(filePath);
message.Attachments.Add(new MailAttachment(filePath));
/** Now we get an error saying file cannot be read */
We've tried both the string filepath shown above and wrapping the path explicitly in a StreamWriter, flushing, and closing it. Is there any reason Document would maintain an open file connection after Draw() has returned?
PDF write lock
Re: PDF write lock
Support · Aug 29, 2006No, there really is nothing in the Draw method that would be maintaining an open connection with the file. The Draw method does internally use a filestream but it closes that filestream before the Draw method returns.
The steps you described above are a very common use of our product and we have not seen (in our own programming and examples) or heard (from other customers) of this error in the past.
Could there be anything else that you are doing or anything else that is happening to the file that is maintaining an open connection? One thing to make sure is that you are using the latest version 4.0 build of our product but it is not likely that this lock would be coming from our product.
Thanks,
ceTe Software Support Team
Re: PDF write lock
Forum member · Aug 29, 2006We tracked it down this morning to a rather bizarre cause: the mail attachment was choking because we used a relative path rather than an absolute. We tacked on a fileroot and it's all working smoothly.
Not helpful that the only error we got was "File could not be read", when the file is obviously right there.
Sorry to bother you.