-
Notifications
You must be signed in to change notification settings - Fork 21
Home
Max edited this page Jan 24, 2019
·
1 revision
Welcome to the GameArchives wiki!
Note: The API is not solidified yet. I'll try to keep this guide up-to-date.
To load a package of any supported format, use the PackageReader.ReadPackageFromFile function. It returns an AbstractPackage instance. AbstractPackage implements IDisposable so be sure to manually call Dispose() or use a using block, or else the file will be left open until your program quits.
using GameArchives;
static class Examples
{
// Example: Extracting a file called "img.png" from the root of a package:
public static void ExtractFile()
{
using (var pkg = PackageReader.ReadPackageFromFile(@"C:\data\file.pkg"))
{
if(pkg.RootDirectory.TryGetFile("img.png", out var file1))
{
using (var fstream = file1.GetStream())
using (var ostream = File.OpenWrite(@"C:\data\img.png"))
{
fstream.CopyTo(ostream);
}
}
}
}
}