B
Bruce
I need to read a file within a web service, but am having (apparently)
permissions problems. Code snip is posted below.
When I attempt to open a filestream to read a file, I get an
UnauthorizedAccessException exception.
I have granted full permissions on the directory to IUSR_machineName,
ASPNET, Network Service, and Local Service accounts. But granting these did
not fix the problem.
Recommendations? Also, how do I determine definatively what account needs
to be granted permissions for an ASP.NET process (or, in this case, a web
service.)
Thanks,
Bruce
------------------------
[WebMethod]
public byte [] GetBitmap()
{
return GetBitmapPrivate();
}
private byte[] GetBitmapPrivate()
{
FileStream fs = null;
FileInfo inf = new FileInfo(IMAGE_FILE_PATH);
try
{
fs = new FileStream(IMAGE_FILE_PATH, FileMode.Open);
}
catch ( Exception ex )
{
Console.WriteLine( ex.ToString() );
}
byte [] bytes = new byte [inf.Length];
fs.Read(bytes, 0, (int)inf.Length);
fs.Close();
return bytes;
}
permissions problems. Code snip is posted below.
When I attempt to open a filestream to read a file, I get an
UnauthorizedAccessException exception.
I have granted full permissions on the directory to IUSR_machineName,
ASPNET, Network Service, and Local Service accounts. But granting these did
not fix the problem.
Recommendations? Also, how do I determine definatively what account needs
to be granted permissions for an ASP.NET process (or, in this case, a web
service.)
Thanks,
Bruce
------------------------
[WebMethod]
public byte [] GetBitmap()
{
return GetBitmapPrivate();
}
private byte[] GetBitmapPrivate()
{
FileStream fs = null;
FileInfo inf = new FileInfo(IMAGE_FILE_PATH);
try
{
fs = new FileStream(IMAGE_FILE_PATH, FileMode.Open);
}
catch ( Exception ex )
{
Console.WriteLine( ex.ToString() );
}
byte [] bytes = new byte [inf.Length];
fs.Read(bytes, 0, (int)inf.Length);
fs.Close();
return bytes;
}