I have been getting emails for many days now saying that Access was denied; however, when I check on the file, it was actually uploaded just fine. As a matter of fact, I have never checked on a file that was not uploaded successfully.
Does anyone know why I might be getting these exceptions even though the SaveAs method seems to be working? Below is an excerpt of my code:
Expand|Select|Wrap|Line Numbers
- if (Day_Photo_1.HasFile)
- {
- //save file
- try
- {
- Day_Photo_1.SaveAs(savePath + "\\Day_Photo_1_" + Day_Photo_1.FileName.ToString());
- result = 0;
- }
- catch (Exception e)
- {
- Errors.Add(e);
- result = 1;
- }
- }
- else
- {
- result = 1;
- }
- ...
- if (Errors.Count > 0)
- {
- string body = "";
- body += "Below is a list of exceptions experienced during the 'UploadImages' routine:<br />";
- foreach (Exception ex in Errors)
- {
- body += "<br /><br />Exception: " + ex.Message;
- }
- System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
- msg.To.Add("me@somesite.com");
- msg.From = new System.Net.Mail.MailAddress("noreply@somesite.com");
- msg.Subject = "A file upload on the form has failed";
- msg.Body = body;
- msg.IsBodyHtml = true;
- System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.somesite.com");
- client.Send(msg);
- }