Board index » delphi » Sharing Violation on attached file even after disconnect

Sharing Violation on attached file even after disconnect


2003-10-17 01:40:07 AM
delphi109
After sending an email with attachment using TIdSMTP and TIdMessage, I
cannot access the file on the hard drive that was the attachment (Sharing
Violation). This is even after IdSMTP.Disconnect. I have also tried
DisconnectSocket and even Destroy, but still no luck. I can only access the
file after I close my application. I am trying to delete the file after
disconnect because it is a temporary file in the TEMP folder. Is there any
way to unlock the file after the Send is completed? Otherwise the TEMP
folder will grow forever.
Thank you for any help that anyone can offer.
 
 

Re:Sharing Violation on attached file even after disconnect

"Chris Mathews" <XXXX@XXXXX.COM>writes
Quote
After sending an email with attachment using TIdSMTP and TIdMessage, I
cannot access the file on the hard drive that was the attachment (Sharing
Violation).
Please show your actual code.
Quote
I am trying to delete the file after disconnect because it is a
temporary file in the TEMP folder.
FYI, TIdAttachment does have a DeleteTempFile property for specifying
whether a TIdAttachment instance automatically deletes its file when the
TIdAttachment itself is freed.
Quote
Is there any way to unlock the file after the Send is completed?
It should already be unlocked. The file is only opened during the encoding
process prior to sending the message, and is closed afterwords. It is not
left open during the send itself at all.
Gambit
 

Re:Sharing Violation on attached file even after disconnect

Thank you for responding. I have found the issue with the locked file. I
will try your "DeleteTempFile" suggestion though for the temp file deletion.
Thanks again,CM
"Remy Lebeau (TeamB)" <XXXX@XXXXX.COM>writes
Quote

"Chris Mathews" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>After sending an email with attachment using TIdSMTP and TIdMessage, I
>cannot access the file on the hard drive that was the attachment
(Sharing
>Violation).

Please show your actual code.

>I am trying to delete the file after disconnect because it is a
>temporary file in the TEMP folder.

FYI, TIdAttachment does have a DeleteTempFile property for specifying
whether a TIdAttachment instance automatically deletes its file when the
TIdAttachment itself is freed.

>Is there any way to unlock the file after the Send is completed?

It should already be unlocked. The file is only opened during the
encoding
process prior to sending the message, and is closed afterwords. It is not
left open during the send itself at all.


Gambit