File Locked after adding it as attachement
Mar 04
I was encountering a problem whereby when I was adding an attachement to be sent by email :-
// Create the file attachment for this e-mail message.
Attachment data = new Attachment(filePath, MediaTypeNames.Application.Octet);
// Add time stamp information for the file.
ContentDisposition disposition = data.ContentDisposition;
disposition.CreationDate = System.IO.File.GetCreationTime(filePath);
disposition.ModificationDate = System.IO.File.GetLastWriteTime(filePath);
disposition.ReadDate = System.IO.File.GetLastAccessTime(filePath);
// Add the file attachment to this e-mail message.
message.Attachments.Add(data);
this same file was being locked and could not be moved to a “processed” folder. Spent a couple of hours tried to figure out why. Then I found out what the problem was.
The line of code that did the trick was
message.Dispose();
Related posts:








Follow Me!