diff --git a/Core/InteropServices/NativeMemoryStream.cs b/Core/InteropServices/NativeMemoryStream.cs
index f06a6cde..23368ba6 100644
--- a/Core/InteropServices/NativeMemoryStream.cs
+++ b/Core/InteropServices/NativeMemoryStream.cs
@@ -49,9 +49,10 @@ namespace Vanara.InteropServices
/// Initializes a new instance of the class with a pointer and allows for dynamic growth.
/// The pointer to unmanaged, preallocated memory.
/// The bytes allocated to .
- public NativeMemoryStream(IntPtr unmanagedPtr, long bytesAllocated)
+ /// The mode of file access to the native memory stream.
+ public NativeMemoryStream(IntPtr unmanagedPtr, long bytesAllocated, FileAccess access = FileAccess.Read)
{
- access = FileAccess.Read;
+ this.access = access;
chunkSize = 0;
Pointer = unmanagedPtr;
MaxCapacity = capacity = bytesAllocated;
@@ -321,7 +322,7 @@ namespace Vanara.InteropServices
/// Writes the specified value into the stream.
/// The type of the value.
/// The value.
- public void Write(in T value) where T : unmanaged => WriteObject(value);
+ public void Write(in T value) where T : struct => WriteObject(value);
/// Writes the specified string into the stream.
/// The string value.
@@ -340,7 +341,7 @@ namespace Vanara.InteropServices
/// The type of the array item.
/// The items.
/// Write values as a referenced array.
- public void Write(IEnumerable items, bool byRef = false) where T : unmanaged
+ public void Write(IEnumerable items, bool byRef = false) where T : struct
{
if (access == FileAccess.Read) throw new NotSupportedException();
if (items == null) return;