TsgcWSAPIKeyManager › Methods › SaveToFile
Persists keys and audit log to the given file (falls back to Storage.FileName when empty).
procedure SaveToFile(const aFileName: string = '');
| Name | Type | Description |
|---|---|---|
aFileName | const string | Destination path. Empty means use Storage.FileName; raises when both are empty. |
Writes the key store (hashes + metadata) and the audit log to a single file, encrypting it with Storage.EncryptionKey when Storage.EncryptAtRest is True. Plaintext keys are never written — only their hashes survive, so SaveToFile is safe on shared or backup storage. The file carries a versioned header (SGCAPIKEYS:1) so a future release can upgrade the format transparently. The background sweep triggers SaveToFile automatically every Storage.AutoSaveSeconds seconds when StorageType is kstFile; call it manually before a controlled shutdown or after a bulk administrative change.
// Explicit flush before shutdown
sgcWSAPIKeyManager1.SaveToFile('apikeys.dat');