我有一個asp.net網站,我已經做了.Dispose()這裏是我的代碼如下;該進程無法訪問該文件,因爲它正在被另一個進程使用
嘗試 {
MailMessage newMail = new MailMessage(MailFrom, MailTo,
MailSubject,的MailMsg);
if (MailAttachment != "") { Attachment data = new Attachment(MailAttachment,
MediaTypeNames.Application.Octet); newMail.Attachments.Add(data); } newMail.BodyEncoding = System.Text.Encoding.UTF8; newMail.IsBodyHtml = true;
SmtpClient client = new SmtpClient("192.168.2.205"); client.Credentials = CredentialCache.DefaultNetworkCredentials; client.Send(newMail); newMail.Attachments.Dispose(); newMail.Dispose(); DeleteAttachment(MailAttachment); lblSuccess.Text = "Başvurunuz alınmıştır teşekkürler."; lblSuccess.Visible = true; ClearForm(); } catch (Exception ex) { lblSuccess.Text = ex.Message; //lblSuccess.Text = "Bir sorun oluştu bir daha deneyiniz."; lblSuccess.Visible = true; }
但我得到同樣的錯誤,它的運行良好,在我的本地主機,但在服務器我越來越此錯誤。我該如何解決它?
也許它被另一個進程使用? 嘗試提供更多信息。 – 2010-05-12 08:13:55
也許更大的代碼片段將有助於 – Midhat 2010-05-12 08:14:34
我編輯並給出了一個更大的代碼片段,希望它會有幫助 – Xenon 2010-05-12 08:19:31