Read the Temporary file name

7 posts, 1 answers
  1. Tony
    Tony avatar
    13 posts
    Member since:
    Dec 2011

    Posted 03 Jul 2013 Link to this post

    Hi, I need to read the temporary filename that RadAsyncUpload has used.

    I have tried the following:

    protected void AttachmentAsyncUpload_OnFileUploaded(object sender, FileUploadedEventArgs e)
            {
                string targetFolder = ((RadAsyncUpload)sender).TargetFolder;
                Response.Write(Server.MapPath(targetFolder + "/" + e.File.FileName));
            }

    but this is not returning the filename on the disk - I need the full temp file name for example: 1372860982657testdoc.jpg and not just testdoc.jpg

    My understanding is that the files are not cleared by default for 4 hours and I need to be able to read the file contents after several postbacks so need to know the temp filenames.

    Thanks
    Tony
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2013 Link to this post

    Hi Tony,

    Based on this forum thread, The temporary filename is not available on the client due to security reasons. The server side code you tried does not return the Temporary file name. In that code Server.MapPath(targetFolder + "/" + e.File.FileName) statement provides the final path of the uploaded file on the server.
    Finally, all processed temporary files are deleted. Temporary files are also deleted after a set amount of time defined by the TemporaryFileExpiration property. If this property is not set, it will be deleted automatically by the .NET framework after 4 hours.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tony
    Tony avatar
    13 posts
    Member since:
    Dec 2011

    Posted 04 Jul 2013 Link to this post

    to be clear - I need to read the temporary filename server-side via c#

    If I iterate the RadAsyncUpload.UploadedFiles list I can see properties of the files and would normally use the

    InputStream to read the file and save but I don't want to save the file at this point - I need the temp filename.

    Using the debugger I expanded non-public members and can see a property TempFilePath  - this has the full path and the temporary filename I need - is there a way (without reflection) to access this property?


    Thanks
    Tony
  5. Plamen
    Admin
    Plamen avatar
    2731 posts

    Posted 09 Jul 2013 Link to this post

    Hello Tony,

     
    Basically Temporary file directory is used only internally in RadAsyncUpload and the files in it should not be modified and that is why they can not be used from the server. 

    Would you please elaborate what exactly are you trying to achieve so we could be more helpful with a possible solution?

    Regards,
    Plamen
    Telerik
    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 the blog feed now.
  6. Tony
    Tony avatar
    13 posts
    Member since:
    Dec 2011

    Posted 09 Jul 2013 Link to this post

    Hi Plamen

    I'm using the asp.net wizard control and on step 3 of 4 I have a RadGrid with the AsyncUpload control as part of the grid.

    When the grid row is saved the form posts back but I dont save the file - I just want to keep a reference to the temporary file name - this appears to be saved with a unique filename which I had planned to use when the wizard is complete?

    Thanks
    Tony
  7. Answer
    Plamen
    Admin
    Plamen avatar
    2731 posts

    Posted 11 Jul 2013 Link to this post

    Hi Tony,

     
    Thank you for elaborating the issue. 

    Unfortunately such behavior is not supported by RadAsyncUpload.  
    The only possible workaround is to persist the uploaded files-please have in mind that this is possible only if the control is rendered on the page.

    Hope this will explain the issue.

    Regards,
    Plamen
    Telerik
    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 the blog feed now.
  8. Johann
    Johann avatar
    3 posts
    Member since:
    Jan 2015

    Posted 12 Feb 2015 Link to this post

    i had the same problem and i could solve it.

    foreach(UploadedFile file in rauUploadFiles.UploadedFiles)
                {
                    FileStream tmpFile = (FileStream) file.InputStream;
                    images = Directory.GetFiles(HttpContext.Current.Server.MapPath("~/temp")).Where(f => f.Equals(tmpFile.Name)).ToList();
                }

    I hope this helps
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017