Orbmu2k/nvidiaProfileInspector · error · NvapiException

DRS_SaveSettingsToFileEx

Error message

DRS_SaveSettingsToFileEx

What it means

NvapiException wrapping a non-OK status from DRS_SaveSettingsToFileEx, which exports the current DRS session's settings to a file. Thrown in SaveSettingsFileEx when the driver fails to write the export — typically an unwritable target path, invalid session, or driver-level failure.

Solutions

  1. Validate the target directory exists and is writable (try creating a temp file) before the export
  2. Catch NvapiException and report the status; fall back to a user-writable path like Documents
  3. Use a short, local path instead of network/protected locations
  4. Ensure the DRS session is alive and prior in-memory changes were applied without error
Defensive patterns

Strategy: validation

Validate before calling

var dir = Path.GetDirectoryName(Path.GetFullPath(filename));
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
using (File.Open(Path.Combine(dir, Path.GetFileName(filename)), FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) { }

Try / catch

try { SaveSettingsFileEx(hSession, filename); }
catch (NvapiException ex) { ShowError($"Export failed ({ex.Status}). Try a local, writable folder."); }

Prevention

When it happens

Trigger: Exporting to a directory that doesn't exist or lacks write permission; target file locked by another process (open in editor, antivirus scan); hSession invalid or already destroyed; extremely long path exceeding MAX_PATH on older Windows.

Common situations: Users exporting profiles to OneDrive/network/protected folders (Program Files); path with restricted permissions; exporting during driver reload.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of Orbmu2k/nvidiaProfileInspector@2f50c388b3 (2026-09-15). Data as JSON: /api/errors/753efbbbf568af0d. Report an issue: GitHub.

Appendix: source

Thrown at nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs:440

        protected void SaveSettings(IntPtr hSession)
        {
            var nvRes = nvw.Instance.DRS_SaveSettings(hSession);
            if (nvRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_SaveSettings", nvRes);
        }

        protected void LoadSettingsFileEx(IntPtr hSession, string filename)
        {
            var nvRes = nvw.Instance.DRS_LoadSettingsFromFileEx(hSession, new StringBuilder(filename));
            if (nvRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_LoadSettingsFromFileEx", nvRes);
        }

        protected void SaveSettingsFileEx(IntPtr hSession, string filename)
        {
            var nvRes = nvw.Instance.DRS_SaveSettingsToFileEx(hSession, new StringBuilder(filename));
            if (nvRes != NvAPI_Status.NVAPI_OK)
                throw new NvapiException("DRS_SaveSettingsToFileEx", nvRes);
        }

    }

}

View on GitHub (pinned to 2f50c388b3)