D
David Veeneman
My web app creates several temporary files, then attaches them to an email
that it sends out. When the app attches the documents to the email, .NET
locks the files. My problem is that they aren't getting unlocked.
When the app runns, the first thing it does is delete the files left from
its last run. So, on the second run of the app, I'm getting this error
message: " The process cannot access the file 'D:\ ... \MyFile.txt' because
it is being used by another process." In other words, the server can't
delete the temporary files because the locks placed on them when they were
attached to the email in the previous run were never released.
I tried adding some code immediately after the email send in an attempt to
get the locks released:
***********************************************************
// Send server error email
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(email);
// Clear attachments
if (email.Attachments.Count > 0)
{
email.Attachments.Clear();
email.Attachments.Dispose();
}
// Dispose email
email.Dispose();
**************************************************************
But that didn't do the trick.
Can anyone tell me how to release the locks placed on files when they are
attached to an email? Thanks.
David Veeneman
Foresight Systems
that it sends out. When the app attches the documents to the email, .NET
locks the files. My problem is that they aren't getting unlocked.
When the app runns, the first thing it does is delete the files left from
its last run. So, on the second run of the app, I'm getting this error
message: " The process cannot access the file 'D:\ ... \MyFile.txt' because
it is being used by another process." In other words, the server can't
delete the temporary files because the locks placed on them when they were
attached to the email in the previous run were never released.
I tried adding some code immediately after the email send in an attempt to
get the locks released:
***********************************************************
// Send server error email
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Send(email);
// Clear attachments
if (email.Attachments.Count > 0)
{
email.Attachments.Clear();
email.Attachments.Dispose();
}
// Dispose email
email.Dispose();
**************************************************************
But that didn't do the trick.
Can anyone tell me how to release the locks placed on files when they are
attached to an email? Thanks.
David Veeneman
Foresight Systems