Closed Kaplas80 closed 3 years ago
Describe the bug Reading a DataStream from a readonly file throws a UnauthorizedAccessException.
DataStream
UnauthorizedAccessException
Seems to happen only in Windows.
To Reproduce
string tempFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); File.WriteAllBytes(tempFile, new byte[] { 0xCA, 0xFE, 0x00, 0xFF }); File.SetAttributes(tempFile, FileAttributes.ReadOnly); Node node = NodeFactory.FromFile(tempFile); byte[] buffer = new byte[4]; _ = node.Stream.Read(buffer, 0, 4); node.Dispose(); File.SetAttributes(tempFile, FileAttributes.Normal); File.Delete(tempFile);
Expected behavior It should read the file contents.
Exceptions
Message: System.UnauthorizedAccessException : Access to the path 'C:\Users\<removed>\AppData\Local\Temp\ojuirizr.zau' is denied. Stack Trace: FileStream.ValidateFileHandle(SafeFileHandle fileHandle) FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) FileStream.ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) FileStream.ctor(String path, FileMode mode, FileAccess access) LazyFileStream.Initialize() line 145 LazyFileStream.Read(Byte[] buffer, Int32 index, Int32 count) line 86 DataStream.Read(Byte[] buffer, Int32 offset, Int32 count) line 475 NodeFactoryTests.ReadFromReadonlyFile() line 616
Describe the bug Reading a
DataStream
from a readonly file throws aUnauthorizedAccessException
.Seems to happen only in Windows.
To Reproduce
Expected behavior It should read the file contents.
Exceptions