I create an XML file that I need to email to users when they register. After creating the XML file I pass it as an attached filename (with ServeMapPath) and the email programs send the email message with file. Yea. However, I then want to delete that file.
It appears the SmtpClient client = new SmtpClient(settings.SMTPServer); is locking the file after sending email. Even if I wait a long time, it remains locked. Using IISExpress from Visual Studio. If I exist Visual Studio and reopen debugging, I can then delete, or overwrite the file one time.
Is this a characteristic of developing under Visual Studio or ??? any work arounds for testing? Will IIS keep the file locked on a production server?