{"record":{"id":"753efbbbf568af0d","repo":"Orbmu2k/nvidiaProfileInspector","slug":"drs-savesettingstofileex","errorCode":null,"errorMessage":"DRS_SaveSettingsToFileEx","messagePattern":"DRS_SaveSettingsToFileEx","errorType":"exception","errorClass":"NvapiException","httpStatus":null,"severity":"error","filePath":"nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs","lineNumber":440,"sourceCode":"        protected void SaveSettings(IntPtr hSession)\n        {\n            var nvRes = nvw.Instance.DRS_SaveSettings(hSession);\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_SaveSettings\", nvRes);\n        }\n\n        protected void LoadSettingsFileEx(IntPtr hSession, string filename)\n        {\n            var nvRes = nvw.Instance.DRS_LoadSettingsFromFileEx(hSession, new StringBuilder(filename));\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_LoadSettingsFromFileEx\", nvRes);\n        }\n\n        protected void SaveSettingsFileEx(IntPtr hSession, string filename)\n        {\n            var nvRes = nvw.Instance.DRS_SaveSettingsToFileEx(hSession, new StringBuilder(filename));\n            if (nvRes != NvAPI_Status.NVAPI_OK)\n                throw new NvapiException(\"DRS_SaveSettingsToFileEx\", nvRes);\n        }\n\n    }\n\n}\n\n","sourceCodeStart":422,"sourceCodeEnd":447,"githubUrl":"https://github.com/Orbmu2k/nvidiaProfileInspector/blob/2f50c388b3a4d661cade66b32746bec096d1eee1/nvidiaProfileInspector/Common/DrsSettingsServiceBase.cs#L422-L447","documentation":"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.","triggerScenarios":"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.","commonSituations":"Users exporting profiles to OneDrive/network/protected folders (Program Files); path with restricted permissions; exporting during driver reload.","solutions":["Validate the target directory exists and is writable (try creating a temp file) before the export","Catch NvapiException and report the status; fall back to a user-writable path like Documents","Use a short, local path instead of network/protected locations","Ensure the DRS session is alive and prior in-memory changes were applied without error"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var dir = Path.GetDirectoryName(Path.GetFullPath(filename));\nif (!Directory.Exists(dir)) Directory.CreateDirectory(dir);\nusing (File.Open(Path.Combine(dir, Path.GetFileName(filename)), FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) { }","typeGuard":null,"tryCatchPattern":"try { SaveSettingsFileEx(hSession, filename); }\ncatch (NvapiException ex) { ShowError($\"Export failed ({ex.Status}). Try a local, writable folder.\"); }","preventionTips":["Ensure the target directory exists and is writable","Avoid exporting to network shares, OneDrive, or Program Files paths","Check the target file isn't locked by another process","Keep the DRS session open and valid until the export completes"],"tags":["nvapi","driver-settings","file-export"],"backgroundTag":"file-write-failed","analyzedSha":"2f50c388b3a4d661cade66b32746bec096d1eee1","analyzedAt":"2026-09-15T05:23:52.218Z","contentChangedAt":"2026-09-15T05:23:52.218Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}