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;
}
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;
}