Skip to the content.

Reading QWK and REP Packets

This guide provides a practical workflow for reading QWK and REP packets with QWK.NET. It covers the essential steps to open, inspect, and process packet files.

For detailed API reference, see the API Overview.

What This Guide Is For

This guide is for developers who need to:

If you’re creating reply packets, see the Writing Packets guide instead.

Simple Workflow

The standard workflow for reading packets follows these steps:

  1. Open - Load the packet from a file, stream, or byte array
  2. Inspect - Access control data (BBS name, creation date, etc.)
  3. Enumerate - Iterate through messages
  4. Validate - Check packet integrity (optional but recommended)
  5. Access optional files - Read WELCOME, NEWS, or other optional files if present

Minimal Example

Here’s a minimal example that demonstrates the core workflow:

using QwkNet;

// 1. Open packet
using QwkPacket packet = QwkPacket.Open("DEMO1.QWK");

// 2. Inspect control data
Console.WriteLine($"BBS: {packet.Control.BbsName}");
Console.WriteLine($"Created: {packet.Control.CreatedAt}");

// 3. Enumerate messages
foreach (Message message in packet.Messages)
{
    Console.WriteLine($"{message.From}{message.To}: {message.Subject}");
}

// 4. Validate (optional)
ValidationReport report = packet.Validate();
if (!report.IsValid)
{
    Console.WriteLine($"Found {report.Errors.Count} errors");
}

// 5. Access optional files (if present)
if (packet.OptionalFiles.HasFile("WELCOME"))
{
    string welcome = packet.OptionalFiles.GetText("WELCOME");
    Console.WriteLine(welcome);
}

Opening Packets

QWK.NET supports opening packets from multiple sources:

See the API Overview for detailed examples of each approach.

Validation Modes

By default, QWK.NET uses Lenient validation mode, which handles real-world format variations gracefully. You can specify a different mode when opening:

For detailed information about validation modes and when to use each, see Validation Modes.

Reading Message Content

Messages contain both header metadata and body content. Access the body through the Body property:

foreach (Message message in packet.Messages)
{
    MessageBody body = message.Body;
    
    // Access lines (0xE3 terminators removed)
    foreach (string line in body.Lines)
    {
        Console.WriteLine(line);
    }
    
    // Or get decoded text with standard line endings
    string text = body.GetDecodedText();
}

For complete message handling examples, see the API Overview.

Troubleshooting

If you encounter issues reading packets:

Further Reading