Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
try to remove these lines:
postedFile.InputStream.Position = 0;
postedFile.InputStream.Seek(0, SeekOrigin.Begin);
I'm using a custom SendEmailAfterSubmissionActor where i override the method Send. The reason if for attaching files to email when user is uploading files in my form.
CopyTo method in postFile.InputStream to MemoryStream i get this error.StackTrace = " at System.IO.__Error.FileNotOpen()\r\n at System.IO.FileStream.Seek(Int64 offset, SeekOrigin origin)\r\n at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)\r\n at Test.Web.Extensions.EpiserverForms
private List<UploadedFile> GetUploadedFiles() { var uploadedFiles = new List<UploadedFile>(); try { for (int i = 0; i < this.HttpRequestContext.Files.Count; i++) { HttpPostedFileBase postedFile = this.HttpRequestContext.Files[i]; postedFile.InputStream.Position = 0; postedFile.InputStream.Seek(0, SeekOrigin.Begin); MemoryStream memoryStream = new MemoryStream(); postedFile.InputStream.CopyTo(memoryStream); memoryStream.Position = 0; memoryStream.Seek(0, SeekOrigin.Begin); uploadedFiles.Add( new UploadedFile() { Name = postedFile.FileName, Type = MimeMapping.GetMimeMapping(postedFile.FileName), InputStream = memoryStream }); } } catch (Exception ex) { PostSubmissionActorBase._logger.Error("Failed to get uploaded files: {0}", ex); } return uploadedFiles; }