The process cannot access the file because it is being used by another process

前端 未结 10 1043
忘了有多久
忘了有多久 2020-11-30 09:38

I have a set of nightly reports.

Sometimes I get the exception:

The process cannot access the file because it is being used by another proce

10条回答
  •  醉梦人生
    2020-11-30 10:27

    Confirmed. I had a similar problem and did what Greg said.

    In finally block after sending the message, I just put this in there, and it released the file handles:

    foreach(Attachment a in message.Attachments) a.Dispose();
    

提交回复
热议问题