我有一个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