4 Answers, 1 is accepted
0
Hello Alex,
The SaveAs method does not work asynchronously as the files are saved one by one.
Regards,
Nencho
Telerik
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.
0

swapnil
Top achievements
Rank 1
Iron
answered on 01 Feb 2019, 11:42 PM
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 ?
0

swapnil
Top achievements
Rank 1
Iron
answered on 01 Feb 2019, 11:56 PM
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);
}
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);
}
0
Hello Swapnil,
Regards,
Marin Bratanov
Progress Telerik
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.