edbrinkm
asked on
File access error using asp.net upload control
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.FileUpl oad1.Poste dFile.File Name))
{
memStream = new MemoryStream();
memStream.SetLength(fileSt ream.Lengt h);
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.PostedFil e.InputStr eam.Length + 1];
//FileUpload1.PostedFile.I nputStream .Read(imag eBytes, 0, imageBytes.Length);
I want to create a memory stream to process the text file. Any tips is greatly appreciated.
The website is using an application pool configured with a service account.
MemoryStream destination = new MemoryStream();
using (FileStream fileStream = File.OpenRead(this.FileUpl
{
memStream = new MemoryStream();
memStream.SetLength(fileSt
fileStream.Read(memStream.
}
Previously, I used the below code successfully to read the file.
////Load FileUpload's InputStream into Byte array
//byte[] imageBytes = new byte[FileUpload1.PostedFil
//FileUpload1.PostedFile.I
I want to create a memory stream to process the text file. Any tips is greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have given the code (help) first, thenafter how can you simply close the post like this as my comment was right.
ASKER
I had attempted that code before. The problem is that it converts the text to a byte array. I need it as a text file/string format.
ASKER
it works. no errors
Stream sw = FileUpload1.PostedFile.Inp
byte[] buffer = new byte[sw.Length];
sw.Read(buffer, 0, buffer.Length);
sw.Close();
Refer : http://forums.asp.net/t/1604848.aspx/1
Hope you will fix up your issue.