hi
after upload a file and save it, when i refresh page with browser refresh button, this error showing:
System.IO.FileNotFoundException: Could not find file 'G:\Project\realpanacea\banners\temp\s0jenl45.iw4'.
is this a bug?
How I can fix it?
7 Answers, 1 is accepted
We are not able to reproduce such exception on our online demos. What version of the controls do you use? Can you please paste here the mark-up of the page that fails and any relevant code-behind. Thank you.
Best wishes,
Genady Sergeev
the Telerik team
this is may codes:
1.
<
telerik:RadAsyncUpload
ID
=
"rauView0BannerFile"
runat
=
"server"
/>
2.
<
asp:Button
ID
=
"btnView0Upload"
runat
=
"server"
OnClick
=
"btnView0Upload_Click"
/>
1.
protected
void
btnView0Upload_Click(
object
sender, EventArgs e)
2.
{
3.
rauView0BannerFile.UploadedFiles[0].SaveAs(MapPath(
"~/files/"
) + rauView0BannerFile.UploadedFiles[0].FileName,
true
);
4.
}
but after this when i refresh page with browser refresh button this error showing:
System.IO.FileNotFoundException: Could not find file 'G:\Project\realpanacea\banners\temp\cty4m5l2.w0q'.
i attach full error report
i test it in all browsers
and my controls version is:2010.1.309.35
This is expected. As the file is once saved, its temporary file counterpart is deleted. When you refresh the page the browsers repeats the last action, however, there is no longer temp file. Hence the error. Why do you need to refresh the page?
Best wishes,
Genady Sergeev
the Telerik team
i don't need to refresh page but i don't want show this error to user and RadAsyncUpload do not have a peropertis or function for checking that temp file deleted or not.
So what should we do?
You can wrap the SaveAs invocation inside Try/Catch and then, in the Catch clause, update a label that says the temp files has already been deleted. Here is some example code:
try
{
rauView0BannerFile.UploadedFiles[0].SaveAs(MapPath(
"~/files/"
) + rauView0BannerFile.UploadedFiles[0].FileName,
true
);
}
catch(System.IO.FileNotFoundException ex)
{
lblError.Text =
"The temporary file has already been deleted"
;
}
Regards,
Genady Sergeev
the Telerik team
Indeed this is true. The SaveAs operation will always clear the temp file. If you want to protect against browser refresh we suggest to use the approach showcased in my previous reply.
Regards,
Genady Sergeev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.