How do I create a .bz2 file instead of a .tar.bz2 file? #384

Open
opened 2026-01-29 22:11:04 +00:00 by claunia · 3 comments
Owner

Originally created by @CaledoniaProject on GitHub (Jan 3, 2020).

The API example shows how to create a .tar.bz2 file

using (Stream stream = File.OpenWrite(tarbz2Path))
using (var writer = WriterFactory.Open(stream, ArchiveType.Tar, CompressionType.BZip2))
{
	zipWriter.Write(Path.GetFileName(filename), filename);
}

Since there's no ArchiveType.None, How can I compress a single file to .bz2 directly? Similar to unix command bzip2 -9 test.txt

Originally created by @CaledoniaProject on GitHub (Jan 3, 2020). The API example shows how to create a .tar.bz2 file ``` using (Stream stream = File.OpenWrite(tarbz2Path)) using (var writer = WriterFactory.Open(stream, ArchiveType.Tar, CompressionType.BZip2)) { zipWriter.Write(Path.GetFileName(filename), filename); } ``` Since there's no ArchiveType.None, How can I compress a single file to .bz2 directly? Similar to unix command `bzip2 -9 test.txt`
claunia added the enhancementquestionup for grabs labels 2026-01-29 22:11:04 +00:00
Author
Owner

@adamhathcock commented on GitHub (Jan 3, 2020):

You'd just use the BZip2Stream directly. I haven't made a nice API for that as there's been no call for it.

If there's a need, it could be added as there'd probably need to be something like it for GZip as well.

@adamhathcock commented on GitHub (Jan 3, 2020): You'd just use the BZip2Stream directly. I haven't made a nice API for that as there's been no call for it. If there's a need, it could be added as there'd probably need to be something like it for GZip as well.
Author
Owner

@CaledoniaProject commented on GitHub (Jan 3, 2020):

You could add ArchiveType.None

@CaledoniaProject commented on GitHub (Jan 3, 2020): You could add ArchiveType.None
Author
Owner

@adamhathcock commented on GitHub (Jan 3, 2020):

You're welcome to submit a pull request.

@adamhathcock commented on GitHub (Jan 3, 2020): You're welcome to submit a pull request.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#384