SessionFile

public static class SessionFile
Static helpers for capturing, persisting and restoring a SessionRecord on disk. The on-disk record lives in Folders.LocalAppDataFolder and is written at shutdown; the next startup reads it and reinstates the documents that were open when the previous session ended.

Fields

FileName

#
public const string FileName = "Session.ghsession"
On-disk filename used to persist the session record.

Properties

Path

#
public static string Path { get; }
Full path to the session record file.

Methods

CaptureCurrent

#
public static SessionRecord CaptureCurrent(DocumentBag bag)
Build a fresh SessionRecord from the current state of a document bag. Every non-empty stack root is captured — named documents reference their on-disk path, unnamed documents reference their runtime identity and an autosave file under Folders.UnnamedFilesFolder.
bag (DocumentBag)
A new record. Never null, but may have zero entries.

TryDelete

#
public static bool TryDelete()
Delete the session record file. The restore path no longer calls this; the next clean shutdown overwrites the record. Available for explicit "forget my session" operations.

TryLoad

#
public static SessionRecord TryLoad()
Read the session record from disk, or return null if no record exists or the file could not be read.

TrySave

#
public static bool TrySave(SessionRecord record)
Write the supplied record to Path, replacing any existing file.
record (SessionRecord)
True on success.