This is a migrated thread and some comments may be shown as answers.

IOException file not found

6 Answers 421 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Michel Bakker
Top achievements
Rank 1
Michel Bakker asked on 19 Jul 2010, 09:29 PM
I'm using the MultipleFileSelection="Automatic" in AsyncUpload  (trail of 2010 Q2) to ensure multiple files can be uploaded. Everything goes well with the uploading of multiple files, but when I write the following code in the Button click event of my form I get an IOException (File Could not find file 'C:\{app dir}\App_Data\RadUploadTemp\3yvza1nr.zhh'.):

            foreach (UploadedFile file in AsyncUpload1.UploadedFiles)
            {
                business.AddPhto(file.InputStream);
            }


The weird thing is that I can see that temporary files are deleted when the postback happends. Sometimes all files are gone, sometimes all the files are there.
My question is: How do I use the uploaded files and what should I do to prevent deletion of temporary files before I have the chance to handle them.

Kind regards,

Michel

6 Answers, 1 is accepted

Sort by
0
Edward Pearson
Top achievements
Rank 1
answered on 20 Jul 2010, 01:19 AM
The same thing is happening to me, however it was fine last week.  Ever since I updated to the latest version of Telerik, I'm getting the System.IO.FileNotFoundException when uploading files.  Just like you, I can see them go in the temp directory, then after a few seconds they disappear, hence the FileNotFoundException after the PostBack event is triggered.  If I click the "Send" button quick enough, it'll work, but that's not acceptable. Here's my mark-up:
<telerik:RadProgressManager runat="server" ID="RadProgressManager1" />  
<telerik:RadAsyncUpload runat="server" 
    ID="RadAsyncUpload1" 
    OnClientFileUploaded="fileUploaded" 
    OnValidatingFile="RadAsyncUpload1_ValidatingFile" 
>  
    <Localization Select="Add File" />  
    <Localization Remove="Remove File" />  
</telerik:RadAsyncUpload>  
<telerik:RadProgressArea runat="server" ID="RadProgressArea1"></telerik:RadProgressArea>


Here's the code-behind for when the PostBack event gets fired:

public void UploadAttachments(object sender, EventArgs e)
{
    if(this.RadAsyncUpload1.UploadedFiles.Count > 0)
    {
        foreach(UploadedFile uploadedFile in this.RadAsyncUpload1.UploadedFiles)
        {
            int bytesRead = 0;
            byte[] documentData = new byte[uploadedFile.ContentLength];
            bytesRead = uploadedFile.InputStream.Read(documentData, 0, uploadedFile.ContentLength);
            // No need to show more code, it breaks here w/ FileNotFoundException...
        }
    }
}

 

0
Tojara
Top achievements
Rank 1
answered on 20 Jul 2010, 06:18 PM
0
Lenny_shp
Top achievements
Rank 2
answered on 21 Jul 2010, 09:30 PM
na
0
Yana
Telerik team
answered on 23 Jul 2010, 01:47 PM
Hello,

The internal build containing the fix for RadAsyncUpload is already uploaded - its version is 2010.2.722.

Sincerely yours,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
louis chan
Top achievements
Rank 1
Iron
answered on 11 Aug 2010, 07:24 AM
I have the same problem too! After I have refreshed my page and uploaded the file, it is working fine.
My version is 2010.2.713.35
0
illumination
Top achievements
Rank 2
answered on 29 Jun 2011, 09:54 PM
I have the same problem too. It was working perfectly before I upgraded to telerik 2011.1.519.35. Now I have all kind of problems because of the upgrade. Please help! 
 
Protected Sub RadAsyncUpload1_FileUploaded(ByVal sender As Object, ByVal e As Telerik.Web.UI.FileUploadedEventArgs) Handles RadAsyncUpload1.FileUploaded 
If RadAsyncUpload1.UploadedFiles.Count > 0 Then 
Try 
Dim validFile As UploadedFile = e.File 
Dim targetFolder As String = Server.MapPath("~/Documents") 
Dim targetFileName As String = System.IO.Path.Combine(targetFolder, validFile.GetNameWithoutExtension & validFile.GetExtension) 
targetFileName = System.IO.Path.Combine(targetFolder, validFile.GetNameWithoutExtension & validFile.GetExtension) 
Dim fileName As String = validFile.GetName() 
'When in the server, we must use this statement: 
'lblUploaded1.Text = "~/" + targetFolder.Split("\")(4) + "/" + fileName 
'When in local testing, we must use this statement: 
lblUploaded1.Text = "~/" + targetFolder.Split("\")(3) + "/" + fileName 
Session("FileName") = lblUploaded1.Text 
validFile.SaveAs(targetFileName) 
Catch ex As Exception 
lblError.Text = ex.Message 
End Try 
End If 
End Sub

And please see the attached file for the error.
Thank you!
Tags
AsyncUpload
Asked by
Michel Bakker
Top achievements
Rank 1
Answers by
Edward Pearson
Top achievements
Rank 1
Tojara
Top achievements
Rank 1
Lenny_shp
Top achievements
Rank 2
Yana
Telerik team
louis chan
Top achievements
Rank 1
Iron
illumination
Top achievements
Rank 2
Share this question
or