Telerik RadAsyncUpload Event OnFileUploaded

http://www.telerik.com/help/aspnet-ajax/asyncupload-overview.html

RadAsyncUpload relies on saving temporary files to work. When posted, files are saved to the designated temp folder (App_Data/RadUploadTemp by default) with unique names.Once a postback occurs the RadAsyncUpload fires theOnFileUploaded event for each file. The target file is passed as part of the arguments to the event and can be set as either valid (default) or invalid. After the events fire, all files marked as valid are automatically saved to the TargetFolder if it’s set.

Finally, all processed temporary files are deleted. Temporary files are also deleted after a set amount of time defined by the TemporaryFileExpiration property.


TemporaryFileExpiration 

Note that when a postback occurs temporary files are either saved as permanent or removed.The expiration time is used only in cases when files are uploadedasynchronously, but a subsequent postback does not occur.

Sample

Default.aspx


     


Default.aspx.cs

        protected void RadButton1_Click(object sender, EventArgs e)
        {
            
        }

        protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
        {
            foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
            {
                byte[] bytes = new byte[file.ContentLength];
                file.InputStream.Read(bytes, 0, file.ContentLength);
                //Insert bytes Into DB
                int i = 2;
            }
        }


Q & A:

1. RadUploadTemp folder not getting cleaned up

http://www.telerik.com/community/forums/aspnet-ajax/async-upload/raduploadtemp-folder-not-getting-cleaned-up.aspx

"Edit: Now I realise that all documents not getting cleand up have a corresponding entry in application log with this warning:"

Process information: 
    Process ID: 5076 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 
 
Exception information: 
    Exception type: IOException 
    Exception message: The process cannot access the file 'C:\Apps\405000\WebSites\PublicWeb\App_Data\RadUploadTemp\1328611694996CVMYDOC-En.pdf' because it is being used by another process. 

Answer:

Your error log provides the exact reason why some of your files are not deleted:
Exception information: 
    Exception type: IOException 
    Exception message: The process cannot access the file 'C:\Apps\405000\WebSites\PublicWeb\App_Data\RadUploadTemp\1328611694996CVMYDOC-En.pdf' because it is being used by another process.


As it appears at the time when your temporary files should be removed, there is some process which is using them.


你可能感兴趣的:(Telerik,exception,postback,file,function,access,object)