IRONSOFTWAREHOME
Load & Save with Streams
using IronWord;

// Load a .docx from any readable stream
using var input = File.OpenRead("input.docx");
WordDocument doc = await WordDocument.LoadAsync(input);

// Save to a stream without touching the disk
using var output = new MemoryStream();
await doc.SaveAsync(output);

// Get the document bytes
byte[] docxBytes = output.ToArray();
NuGet Download
PM > Install-Package IronWord
Load & Save with Streams

Load & Save with Streams

A Word document that arrives as a stream - an upload body, a blob-storage download, or an in-memory buffer - can be loaded and saved without writing a temporary file to disk. The code example above reads a .docx from any readable stream asynchronously, saves the result into a MemoryStream, and extracts the final bytes as an array.

5-Step Guide to Loading and Saving a Word Document in Memory

  • Install IronWord via NuGet
  • Open or receive a readable stream containing .docx bytes
  • Load the document asynchronously from the stream with WordDocument.LoadAsync
  • Save the document into a new MemoryStream with SaveAsync
  • Extract the byte array with ToArray for downstream use

Code Explanation

WordDocument.LoadAsync(Stream) reads the document from the stream's current position to the end; WordDocument(Stream) is the synchronous equivalent. SaveAsync(Stream) writes the serialized .docx bytes into the target stream at its current position; Save(Stream) is the synchronous equivalent. The caller owns both streams - IronWord does not close them, which is why both carry a using declaration. A reused output stream must be emptied with SetLength(0) before saving, because the save does not truncate it. ToArray() reads the entire backing buffer regardless of the stream's position, so no rewind is needed to obtain the bytes after saving.

Explore Loading and Saving Word Documents with Streams

Ready to Get Started?

Nuget Downloads 58,016Version:2026.10just released

Key in blue circle

Get your free 30-day Trial Key instantly

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronWord
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get a Quote, No Obligation
Your details will always be kept confidential.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Trusted by Millions of Engineers Worldwide
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.10

PM > Install-Package IronWord
nuget.org/packages/IronWord/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronWord"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.10

  1. Download and unzip IronWord to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronWord.dll"

Licenses from $999