You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System;
using System.IO;
using System.IO.Packaging;
class Program
{
public static void Main()
{
var ms = new MemoryStream();
Package package = Package.Open(ms, FileMode.OpenOrCreate);
Uri partUri = new Uri("/example.txt", UriKind.Relative);
PackagePart packagePart = package.CreatePart(partUri, "text/plain");
using (StreamWriter writer = new StreamWriter(packagePart.GetStream(FileMode.Create, FileAccess.Write)))
{
writer.Write("Hello, world!");
}
// Replacing package.Flush with package.Close() everything works fine
package.Flush();
File.WriteAllBytes("MyFile.zip", ms.GetBuffer());
}
}
Expected behavior
Save the right content without closing the package
Actual behavior
The file is truncated (or empty)
Regression?
It works with net48
Known Workarounds
No response
Configuration
Which version of .NET is the code running on? net8.0 (it works with net48
What OS and version, and what distro if applicable? Windows 11
What is the architecture (x64, x86, ARM, ARM64)? x64
Do you know whether it is specific to that configuration? It is specific with net8.0 configuration. net48 works*
Other information
No response
The text was updated successfully, but these errors were encountered:
Description
net8.0
Calling Package.Flush does not flush.
Calling Package.Close works.
net48
Works fine
Reproduction Steps
Make console application with 2 Target Frameworks
Running net48 executable works, running net8.0 executable the MyFile.zip is empty
MyProj.csproj
Program.cs
Expected behavior
Save the right content without closing the package
Actual behavior
The file is truncated (or empty)
Regression?
It works with net48
Known Workarounds
No response
Configuration
Which version of .NET is the code running on?
net8.0 (it works with net48
What OS and version, and what distro if applicable?
Windows 11
What is the architecture (x64, x86, ARM, ARM64)?
x64
Do you know whether it is specific to that configuration?
It is specific with net8.0 configuration. net48 works*
Other information
No response
The text was updated successfully, but these errors were encountered: