Reputation: 3034
if (File.Exists(Path))
{
using (FileStream stream = new FileStream(Path, FileMode.Open))
{
this.LoadReport(stream);
}
}
Path file having read only permission only. Got exception while reading, if I remove read only attribute from file properties working. How to resolve this one? Access to the path 'path' is denied. Got this exception
Upvotes: 0
Views: 72
Reputation: 23183
Try define FileAccess
this way:
FileStream stream = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read)
Added:
FileShare.Read
is default so this is enough:
FileStream stream = new FileStream(Path, FileMode.Open, FileAccess.Read)
FileStream Constructor (String, FileMode, FileAccess) on MSDN.
Upvotes: 6