is UploadedFile.SaveAs asynchronous?

5 posts, 0 answers
  1. Alex
    Alex avatar
    3 posts
    Member since:
    Aug 2014

    Posted 16 Dec 2014 Link to this post

    is UploadedFile.SaveAs asynchronous?
  2. Nencho
    Admin
    Nencho avatar
    1818 posts

    Posted 19 Dec 2014 Link to this post

    Hello Alex,

    The SaveAs method does not work asynchronously as the files are saved one by one.

    Regards,
    Nencho
    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.

     
  3. swapnil
    swapnil avatar
    6 posts
    Member since:
    Jan 2009

    Posted 01 Feb in reply to Nencho Link to this post

    I do UploadedFile.SaveAs(path) it saves file to disk successfully, this uploadedFile has one property InputStream , this inputstream becomes null as soon as .SaveAs method is completed. i want to use this inputstream after SaveAs method is executed. How i can achieve this ?
  4. swapnil
    swapnil avatar
    6 posts
    Member since:
    Jan 2009

    Posted 01 Feb in reply to swapnil Link to this post

    I do UploadedFile.SaveAs(path) it saves file to disk successfully, this uploadedFile has one property InputStream , this inputstream becomes null as soon as .SaveAs method is completed. i want to use this inputstream after SaveAs method is executed. How i can achieve this ?
    public void Upload(UploadedFile file, string entityValue, string path, string domain, string org, string repNum, string entityType)
            {
                   file.SaveAs(path); // This save file to local disk successfully
    // After above line executes file.inputStrream becomes null and my obj.Upload method fails, how to fix this ?
                    
                    obj.Upload(file, entityValue, path, domain, org, repNum, entityType);
                

            }
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4819 posts

    Posted 04 Feb Link to this post

    Hello Swapnil,

    You need to open a new stream from the new file you just created, the old file (in the temporary folder) is now deleted (that's what file.SaveAs() does) and so its stream should be expected to be null as it does not exist anymore.

    An alternative is to use the stream to do the desired operation (e.g., write the files somewhere else, like in a database) and only then call .SaveAs().


    Regards,
    Marin Bratanov
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top