I recently updated the Telerik Silverlight DLL files for a project from 2009 Q2 to the Q3 release (most recent at present). Previously the RadUpload control worked fine with the upload handler that I had created. Upon updating the DLL files, all uploads worked perfectly when running locally in a development environment. Once the control was moved onto the production server, however, files that were roughly 1MB in size or larger have begun to error out on an intermittent basis with the following error message:
"Cannot save the file: [The process cannot access the file '<<Insert file name here>>' because it is being used by another process.]"
The following are the essentials of the upload handler. While I would love to think that the failure is my own faulty coding in the upload handler and that I might come across a solution rapidly by way of correcting my own errors, I don't believe this to be the case. I have implemented the process shown below in several different manners through overriding several different base functions. All error out the same. Eventually, I went ahead and just used all base processes with no overridden code and the same errors persisted.
I also am rather certain that the error is not dealing with any code pertaining to the last chunk of data as the .IsFinalFileRequest() method call is not reached. If it were, the first event to occur would be a database update that wouldn't error out. The update doesn't occur, and, just in case, when capturing any errors in the database updates in a try-catch, none are captured. Therefore, it is safe to conclude (I think) that the error has nothing to do with the final chunk of data.
The only other relevant information that I can give is that the control has been styled to mimic the WebBlue theme from the ASP.NET controls. I don't see how this could or would affect anything, but I've been wrong before...
The final bit of testing that I did was to revert the RadUploadHandler.dll file to its Q2 and Q1 versions. Both produced the same error.
Is there an error that I am making that I am not thinking of, or is this possibly a bug in the Q3 upload control?
"Cannot save the file: [The process cannot access the file '<<Insert file name here>>' because it is being used by another process.]"
The following are the essentials of the upload handler. While I would love to think that the failure is my own faulty coding in the upload handler and that I might come across a solution rapidly by way of correcting my own errors, I don't believe this to be the case. I have implemented the process shown below in several different manners through overriding several different base functions. All error out the same. Eventually, I went ahead and just used all base processes with no overridden code and the same errors persisted.
using Telerik.Windows.Controls; |
using System.Collections.Generic; |
using System.Data.SqlClient; |
using System.IO; |
using System; |
public class RadUploadHandler : Telerik.Windows.RadUploadHandler, System.Web.SessionState.IRequiresSessionState |
{ |
public override string TargetPhysicalFolder |
{ |
get |
{ |
string BatchID = "9" + DateTime.Now.Year.ToString() + Right("0" + DateTime.Now.Month.ToString(), 2); |
return Context.Server.MapPath("~\\") + "files\\" + BatchID; |
} |
} |
public override void ProcessStream() |
{ |
if (this.IsNewFileRequest()) |
{ |
if (!Directory.Exists(TargetPhysicalFolder)) |
{ |
//Create Directory |
Directory.CreateDirectory(TargetPhysicalFolder); |
} |
} |
base.ProcessStream(); |
if (this.IsFinalFileRequest()) |
{ |
try |
{ |
/* The omitted code performs database updates pertinent only to the |
specific business application of the control */ |
} |
catch (Exception ex) { Context.Session["error"] = ex.Message; } |
try |
{ |
File.Move(Context.Server.MapPath("~\\") + "files\\" + BatchID.ToString() + "\\" + oldFileName, Context.Server.MapPath("~\\") + "files\\" + BatchID.ToString() + "\\" + fileName); |
} |
catch (Exception ex) { Context.Session["error"] = ex.Message; } |
} |
} |
} |
I also am rather certain that the error is not dealing with any code pertaining to the last chunk of data as the .IsFinalFileRequest() method call is not reached. If it were, the first event to occur would be a database update that wouldn't error out. The update doesn't occur, and, just in case, when capturing any errors in the database updates in a try-catch, none are captured. Therefore, it is safe to conclude (I think) that the error has nothing to do with the final chunk of data.
The only other relevant information that I can give is that the control has been styled to mimic the WebBlue theme from the ASP.NET controls. I don't see how this could or would affect anything, but I've been wrong before...
The final bit of testing that I did was to revert the RadUploadHandler.dll file to its Q2 and Q1 versions. Both produced the same error.
Is there an error that I am making that I am not thinking of, or is this possibly a bug in the Q3 upload control?