Could not find file after refresh page

8 posts, 0 answers
  1. mastermehdi
    mastermehdi avatar
    39 posts
    Member since:
    Apr 2010

    Posted 05 Jul 2010 Link to this post

    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?

  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 06 Jul 2010 Link to this post

    Hello mehdi ghasemi,

    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
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mastermehdi
    mastermehdi avatar
    39 posts
    Member since:
    Apr 2010

    Posted 09 Jul 2010 Link to this post

    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.}
    when i upload a file and click on submit button it is work fine

    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

  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 14 Jul 2010 Link to this post

    Hello mastermehdi,

    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
    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
  6. mastermehdi
    mastermehdi avatar
    39 posts
    Member since:
    Apr 2010

    Posted 15 Jul 2010 Link to this post

    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?

  7. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 16 Jul 2010 Link to this post

    Hello mastermehdi,

    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
    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
  8. Stein
    Stein avatar
    25 posts
    Member since:
    Apr 2008

    Posted 29 Sep 2014 in reply to Genady Sergeev Link to this post

    Genady: It seems that the uploaded file is deleted when using validFile.SaveAs (and the overwrite-flag to true), when refreshing the page (which causes the upload-function to trigger without having the tempfiles anymore).
  9. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 02 Oct 2014 Link to this post

    Hi Stein,

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017