|
Rank: Newbie Groups: Member
Joined: 3/13/2008 Posts: 5
|
I'm new to EO and AJAX, so please bear with me...
When using Firefox to upload a file with an embedded space in the file name, I'm getting this error from the server:
Server Error in '/FileIT' Application. The process cannot access the file because it is being used by another process. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.IOException: The process cannot access the file because it is being used by another process.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[IOException: The process cannot access the file because it is being used by another process.] System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2056653 System.IO.__Error.WinIOError() +30 System.IO.File.Move(String sourceFileName, String destFileName) +258 EO.Web.AJAXUploader.d() +415 System.Web.UI.Page.RaiseChangedEvents() +117 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1646
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
The file also stays in the temp folder. IE works fine. The file name on the client is: update_40724a_ftp passive.zip
How can I trap this error?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, The problem appears to occurs when the uploader attempt to move file from TempFileLocation to FinalFileLocation. We will look into it and see what we can find; in the mean time, you can get around the problem by moving the file manually: 1. Clear the uploader's FinalFileLocation; 2. Handle the uploader's FileUploaded event; 3. Inside the event handler you can do something like this:
Code: C#
foreach (EO.Web.AJAXPostedFile file in AJAXUploader1.PostedFiles)
{
//Move the file first
File.Move(file.TempFileName, anywhere_you_want);
//Now process the file
....
}
Please let us know how that goes. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/13/2008 Posts: 5
|
That works!
Thanks for the fast reply and 'work around'.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Cool. Thanks for the update!
|
|
Rank: Newbie Groups: Member
Joined: 12/4/2009 Posts: 5
|
Hi,
Is the above workaround a final solution to this issue, or is there a better one? I am already using this manual move code in my application and still having the same problem (intermittently). Maybe I should insert a delay or something to allow the the uploader to relinquish the file before I try to move it? (but I am not sure where to put the delay). Here is my code:
Protected Sub AJAXUploader_FileUploaded() 'Handles AjaxUploader.FileUploaded 'Get all the posted files
Dim files As EO.Web.AJAXPostedFile() = AjaxUploader1.PostedFiles
'Gather file info
Dim file As EO.Web.AJAXPostedFile Dim tempFileName As String Dim finalFileName As String Dim filePath As String = "Files/" & dropbox_id & "/" Dim finalFilePathName As String Dim fileSize As Int64 For Each file In files tempFileName = file.TempFileName 'Create the final file name based on the original file name finalFileName = file.ClientFileName ' filename already validated finalFileName = Regex.Replace(finalFileName, "\s+", "_") finalFilePathName = filePath & finalFileName
'Move the file to the desired location If Not System.IO.File.Exists(MapPath(finalFilePathName)) Then fileSize = file.Length ' quota has already been checked System.IO.File.Move(tempFileName, MapPath(finalFilePathName))
' update database itemSDS.InsertParameters("dropbox_id").DefaultValue = dropbox_id itemSDS.InsertParameters("fileName").DefaultValue = finalFileName itemSDS.InsertParameters("fileSize").DefaultValue = fileSize itemSDS.InsertParameters("createdby").DefaultValue = Session("username") itemSDS.InsertParameters("createdip").DefaultValue = Session("userIP") itemSDS.Insert() Else lblError.Text = "That file already exists in the file store: " & finalFileName AjaxUploader1.ClearPostedFiles() db_status = 0 Exit Sub End If Next file AjaxUploader1.ClearPostedFiles() End Sub 'AJAXUploader1_FileUploaded
Thanks.
-- Ned
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You will want to find out who is accessing those files. Usually this occurs when you have some anti-Virus program or index service running on your server. Those programs sit in the background and try to examine new files when they see one. If you (or the uploader) try to move the file while they are examining it, then your code or the uploader will fail.
If you can find out which program is checking the files, you can just either turn it off, or at least configure it not to check your uploader’s temp folder. If you can not find out which program, then you will have to write some code to retry at a later time.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 12/4/2009 Posts: 5
|
Thanks, we did have an antivirus on the server and so we've excluded the temp_upload folder; will see if that helps. That would also explain why we mostly have trouble with large .exe files.
|
|