473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

FileUpload error that isn't actually erroring ???

I have multiple FileUpload controls on the same page (about 30). I have a try...catch around the SaveAs Method for each of these controls. If an exception is caught, it adds the exception to a List<Exception> and after attempting to save all uploads, if the Exception List has any items, I get an email.

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
  1. if (Day_Photo_1.HasFile)
  2. {
  3.     //save file
  4.     try
  5.     {
  6.         Day_Photo_1.SaveAs(savePath + "\\Day_Photo_1_" + Day_Photo_1.FileName.ToString());
  7.         result = 0;
  8.     }
  9.     catch (Exception e)
  10.     {
  11.         Errors.Add(e);
  12.         result = 1;
  13.     }
  14. }
  15. else
  16. {
  17.     result = 1;
  18. }
  19.  
  20. ...
  21.  
  22. if (Errors.Count > 0)
  23. {
  24.     string body = "";
  25.  
  26.     body += "Below is a list of exceptions experienced during the 'UploadImages' routine:<br />";
  27.  
  28.     foreach (Exception ex in Errors)
  29.     {
  30.         body += "<br /><br />Exception: " + ex.Message;
  31.     }
  32.  
  33.     System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
  34.     msg.To.Add("me@somesite.com");
  35.     msg.From = new System.Net.Mail.MailAddress("noreply@somesite.com");
  36.     msg.Subject = "A file upload on the form has failed";
  37.     msg.Body = body;
  38.     msg.IsBodyHtml = true;
  39.  
  40.     System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.somesite.com");
  41.     client.Send(msg);
  42.  
  43. }
  44.  
Feb 16 '12 #1
0 1261

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mensan | last post by:
I am trying to compute the differnece between two dwords in visual basic and keep getting the wrong value being computed. I have the following structure defind: Public Type HighLowQuote...
2
by: Matt | last post by:
All parts of this application is written in VB 6.0. I have a dll on the server registered through COM+ and have exported it to a msi that's been installed on the workstation. Some of the time,...
2
by: John Smith | last post by:
Hi, I am just trying to do a fairly boring bit of DB maintainence that involves getting the correct ID from table2 by matching it with the email field of table2, easy I thought ! ...
3
by: NK | last post by:
Hello, I am a beginner of DB2 and I am in a trouble that I can't access to sample database. Please see below. ENV : OS AIX-5.2/ DB2 8.1.2 SYMPTOM: I don't have any DB2 client terminal so...
1
by: Lorraine | last post by:
Hi all, I have test application written in C# from which I am trying to dynamically invoke a DLL. I have two dll's the only difference being one is written in C# and the other in VB.NET. The test...
4
by: MLH | last post by:
I seem to remember the code below working before. But, today, it is not. Instead, I get a 2450 error complaining that it cannot find the named form. This is true regardless of which form name I...
8
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :)...
11
by: jakester | last post by:
I am using Visual C++ 2007 to build the code below. I keep getting linkage error. Could someone please tell me what I am doing wrong? The code works until I start using namespace for my objects. ...
3
by: =?Utf-8?B?Z296ZXI2MQ==?= | last post by:
Something happened to my development environment and I'm getting an error that hasn't happened before. Not knowing why the error is popping up is preventing me from figuring out what in my...
3
by: A. W. Dunstan | last post by:
I'm creating a socket as follows: m_networkSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); m_networkSocket.LingerState = new LingerOption(true, 1);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.