my codes upload files with RadAsyncUpload (telerik.web.ui version 2012.3.1016.40), when I uploaded single file, the server event FileUploaded worked well. But when I selected multiple files to upload, the FileUploaded event throw FileNotFoundException at SaveAs(...).
I monitored the temporary folder while uploaded multiple files, all files were uploaded and stored in the temporary folder, but after the first one or two uploaded file(s) were successfully saved, the other files disappeared (were deleted). so when the codes ran to SaveAs, it threw FileNotFoundException. I didn't set TemporaryFileExpiration, so it should be default (4 hours).
So, my question is why those files disappeared after the first files were saved?
the aspx file section:
=========================================
the c# code in FileUploaded event:
==========================================
I monitored the temporary folder while uploaded multiple files, all files were uploaded and stored in the temporary folder, but after the first one or two uploaded file(s) were successfully saved, the other files disappeared (were deleted). so when the codes ran to SaveAs, it threw FileNotFoundException. I didn't set TemporaryFileExpiration, so it should be default (4 hours).
So, my question is why those files disappeared after the first files were saved?
the aspx file section:
=========================================
<
div
id
=
"uploader"
>
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
Culture
=
"zh-CN"
EnableEmbeddedSkins
=
"False"
EnableInlineProgress
=
"false"
TemporaryFolder
=
"~/Temp"
Skin
=
"Windows7"
OnFileUploaded
=
"RadAsyncUpload1_FileUploaded"
AllowedFileExtensions
=
"mp3,wav"
MultipleFileSelection
=
"Automatic"
>
</
telerik:RadAsyncUpload
>
<
asp:Button
ID
=
"Upload"
runat
=
"server"
ClientIDMode
=
"Static"
Text
=
"Upload"
Enabled
=
"true"
/>
<
telerik:RadProgressManager
ID
=
"RadProgressManager1"
runat
=
"server"
RefreshPeriod
=
"10"
/>
<
telerik:RadProgressArea
ID
=
"RadProgressArea1"
runat
=
"server"
DisplayCancelButton
=
"true"
EnableEmbeddedSkins
=
"false"
Skin
=
"Windows7"
Culture
=
"zh-CN"
>
</
telerik:RadProgressArea
>
</
div
>
the c# code in FileUploaded event:
==========================================
protected
void
RadAsyncUpload1_FileUploaded(
object
sender, FileUploadedEventArgs e)
{
string
filewebpath =
"Upload/"
+ System.DateTime.Now.ToString(
"yyyy-MM-dd"
) +
"/"
+ ddlWorkSegment.SelectedItem.Text;
string
filelocalpath = Server.MapPath(
"~/"
+ filewebpath);
string
fileduration =
""
;
MembershipUser u = Membership.GetUser(User.Identity.Name);
// create|check target folder
if
(!System.IO.Directory.Exists(filelocalpath))
{
try
{
System.IO.Directory.CreateDirectory(filelocalpath);
}
catch
(Exception ex)
{
throw
ex;
}
}
foreach
(UploadedFile uf
in
RadAsyncUpload1.UploadedFiles)
{
uf.SaveAs(filelocalpath +
"\\"
+ uf.FileName.ToLower(),
true
);
// here is codes for inserting file information into database
}
// refresh gridview to show file list
gdvwFileList.DataSourceID = sqldsFileList.ID;
}