File access error using asp.net upload control
Posted on 2012-04-04
I have an asp.net website that gets an access denied error when executing the below code.
The website is using an application pool configured with a service account.
MemoryStream destination = new MemoryStream();
using (FileStream fileStream = File.OpenRead(this.FileUpload1.PostedFile.FileName))
memStream = new MemoryStream();
fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
Previously, I used the below code successfully to read the file.
////Load FileUpload's InputStream into Byte array
//byte imageBytes = new byte[FileUpload1.PostedFile.InputStream.Length + 1];
//FileUpload1.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length);
I want to create a memory stream to process the text file. Any tips is greatly appreciated.