FileNotFoundException

4 posts, 1 answers
  1. Dave
    Dave avatar
    12 posts
    Member since:
    Jun 2012

    Posted 17 Jan 2013 Link to this post

    I am using RadAsyncUpload and cannot get it to work with more than one file.  

    Basically, I'm using the FileUploaded event to save the file as a different filename (using a GUID) to ensure uniqueness.

    This is what i am seeing (an example that I stepped through):

    1. I upload two files on my form
    2. After selecting the files and the status says they are complete, they are in the App_Data\Uploasd folder as:

    fvcjn4uc.ls0
    RadUploadTestFile
    skhgx0p0.0at

    3. I post the page

    4. I step through and let it go through the first file, and it works, and I see that fvcjn4uc.ls0 is removed from App_Data\Uploads (e.g. only skhgx0p0.0at and RadUploadTestFile remains).

    5. I then go through the next item in the foreach loop and it can access the filename and extension fine but when it does e.File.SaveAs(newFilename) I get (full path removed w/"HIDDEN"):

    Could not find file 'C:\TFS\2010\[HIDDEN]\App_Data\Uploads\fvcjn4uc.ls0'.

    But that's the filename of the FIRST file that was removed, why is it trying to access this again?
       
    Code:


            protected void RadAsyncUploadAttachments_FileUploaded(object sender, FileUploadedEventArgs e)
            {
                try
                {
                    foreach (UploadedFile newfile in RadAsyncUploadAttachments.UploadedFiles)
                    {
                        if (newfile != null)
                        {
                            string originalFilename = newfile.FileName;
                            string filename = Guid.NewGuid().ToString() + newfile.GetExtension();
                            string newFilename = RadAsyncUploadAttachments.TargetFolder + @"\" + filename;

                            e.File.SaveAs(newFilename);
                        }
                    }
                }

                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }      

    What am I missing?

    Thanks,

    Dave
  2. Answer
    Plamen
    Admin
    Plamen avatar
    2733 posts

    Posted 22 Jan 2013 Link to this post

    Hello Dave,

     
    Thank you for contacting Telerik support.

    I have inspected the code provided. It seems that the issue is caused because of the "foreach" function itself -you actually do not need it because OnFileUploaded is fired for every uploaded file separately.

    Hope this will explain the issue. If you have further questions please don't hesitate to contact us again.

    Regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave
    Dave avatar
    12 posts
    Member since:
    Jun 2012

    Posted 22 Jan 2013 Link to this post

    Ok, that makes sense, I thought it fired once but after reading this that wouldn't make any sense.   I'll my my adjustments and test and post my results.  Thanks.

  5. Dave
    Dave avatar
    12 posts
    Member since:
    Jun 2012

    Posted 22 Jan 2013 Link to this post

    That was it.  I was able to get this to work now.

    Thanks for your help.

Back to Top