Odd Filestream reading file permissions error

L

lh

The following method only works when i give the ASP.net account full
permissions on the directory.
It doesn't work when i give the directory Modify, Read &Execute, List Folder
Contents, Read, and Write permissions (all at the same time)
I'm only trying to READ the file. Why do i have to give it full
permissions?
public static string ReadFileContents(string filePath)

{

//open file


FileStream fileStream = new FileStream(filePath,FileMode.Open);

if(!fileStream.CanRead)

{

// close it and reopen for read

string fileName = fileStream.Name;

fileStream.Close();

fileStream = new FileStream(fileName,FileMode.Open,FileAccess.Read);

}

StreamReader streamReader = new StreamReader(fileStream);

string contents = streamReader.ReadToEnd();

streamReader.Close();

return contents;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top