Skip to content

docs: open ODT output files with File.Create instead of File.OpenWrite - #224

Merged
vaceslav merged 2 commits into
mainfrom
docs/file-create-output
Sep 26, 2026
Merged

vaceslav merged 2 commits into
mainfrom
docs/file-create-output

Conversation

@vaceslav

Copy link
Copy Markdown
Contributor

Follow-up to #138 (closed), from the independent review of the OpenDocument support.

Problem

docs/for-developers/opendocument.md recommended File.OpenWrite for the output stream. File.OpenWrite does not truncate. When it overwrites an existing, longer file, the old bytes after the new content remain, and the result is a corrupt ZIP. #221 now cuts off seekable outputs in OdtPackage.Save, but the docs should not depend on that or teach the pattern.

Fix

  • The "Streams and Byte Arrays" sample uses File.Create, which creates or truncates the file.
  • The requirements list says the output stream only has to be writable. It recommends File.Create for files and explains the truncation problem with File.OpenWrite.
  • The "Memory Use" note on cutting off seekable outputs now says to prefer File.Create anyway.
  • I checked every doc, README and XML doc for File.OpenWrite. The DOCX docs (quick-start.md, Examples.md) already use File.Create and mention File.OpenWrite only as the write-only stream that fails, so they stay as they are. The OdtPackage XML doc is part of the package work and is not changed here.

Tests

  • OpenDocumentSamplesTests mirrors the changed sample, which now uses File.Create (renamed to OdtTemplateProcessor_BytesAndOutputStream). OdtPackageTests still covers write-only outputs and truncation.
  • mkdocs build --strict, the Release CI build, all tests on net10/9/8, dotnet format --verify-no-changes and dotnet pack pass.

Public API impact: none (documentation only).

…ite can corrupt (#138)

Found by the independent review of the OpenDocument support.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@vaceslav
vaceslav merged commit 001b4f3 into main Sep 26, 2026
12 checks passed
@vaceslav
vaceslav deleted the docs/file-create-output branch September 26, 2026 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants