Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions openxml4Net/OPC/Internal/MemoryPackagePart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ protected override Stream GetInputStreamImpl()
{
return new MemoryStream();
}
MemoryStream newMs = new MemoryStream((int)data.Length);
data.Position = 0;
StreamHelper.CopyStream(data, newMs);
newMs.Position = 0;
return newMs;
return new MemoryStream(data.GetBuffer(), 0, (int)data.Length, writable: false);
}

protected override Stream GetOutputStreamImpl()
Expand Down
9 changes: 1 addition & 8 deletions openxml4Net/OPC/StreamHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,7 @@ public static void SaveXmlInStream(XmlDocument xmlContent,
*/
public static void CopyStream(Stream inStream, Stream outStream)
{
byte[] buffer = new byte[1024];
int bytesRead = 0;
int totalRead = 0;
while ((bytesRead = inStream.Read(buffer, 0, buffer.Length)) > 0)
{
outStream.Write(buffer, 0, bytesRead);
totalRead += bytesRead;
}
inStream.CopyTo(outStream);
}
}

Expand Down
Loading