{"record":{"id":"d4913767fdf71d2c","repo":"OdysseusYuan/LKY_OfficeTools","slug":"sdk-pkg-path","errorCode":null,"errorMessage":"无法写出 SDK 文件 {pkg_path} 到硬盘！","messagePattern":"无法写出 SDK 文件 (.+?) 到硬盘！","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"critical","filePath":"LKY_OfficeTools/Lib/Lib_AppSdk.cs","lineNumber":114,"sourceCode":"                Thread.Sleep(1000);      //短暂间隔，提升下体验\n                new Log($\"     >> 此过程会持续些许时间，这取决于您的电脑硬件配置，请耐心等待 ...\", ConsoleColor.DarkYellow);\n\n                //初始化前先清理SDK目录，防止因为文件已经存在，引发解压的catch\n                Clean();\n\n                //释放文件\n                if (SdkPackageDic == null)\n                {\n                    throw new Exception(\"读取 SDK 内存资源失败！\");\n                }\n                foreach (var now_pkg in SdkPackageDic)\n                {\n                    string pkg_path = SdkPkgPath[now_pkg.Key];\n                    bool isToDisk = Com_FileOS.Write.FromStream(now_pkg.Value, pkg_path);\n                    if (!isToDisk)\n                    {\n                        //写出异常，抛出\n                        throw new IOException($\"无法写出 SDK 文件 {pkg_path} 到硬盘！\");\n                    }\n\n                    //无异常，解压包\n                    ZipFile.ExtractToDirectory(pkg_path, Documents.SDKs.SDKs_Root + $@\"\\{now_pkg.Key}\");\n                }\n\n                new Log($\"     √ 已完成 {AppAttribute.AppName} 组件配置。\", ConsoleColor.DarkGreen);\n\n                return true;\n            }\n            catch (IOException IO_Ex)\n            {\n                new Log(IO_Ex.ToString());\n\n                //读写出现意外\n                new Log($\"     × 配置 {AppAttribute.AppName} 基础组件失败。请确保您的系统盘具备足够的可写空间！\", ConsoleColor.DarkRed);\n\n                //清理SDK缓存","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/OdysseusYuan/LKY_OfficeTools/blob/6f9a1bd471918f3310e6be4a6d7f42d0d6e467cf/LKY_OfficeTools/Lib/Lib_AppSdk.cs#L96-L132","documentation":"Thrown in Lib_AppSdk.Initial when Com_FileOS.Write.FromStream returns false for a given pkg_path (Lib_AppSdk.cs:110-114), wrapped as IOException. FromStream returning false means writing the embedded SDK package to disk failed. Initial's IOException catch logs it, tells the user to ensure enough writable space on the system drive, cleans the SDK dir, and calls KeyMsg.Quit(-2) (Lib_AppSdk.cs:125-141).","triggerScenarios":"The system drive (where Documents.SDKs.SDKs_Root lives) is full; the path is too long (>260 chars); a file lock or antivirus blocks the write; or the target directory cannot be created. FromStream returns false for any of these write failures.","commonSituations":"Low-disk-space VMs used for testing; path-length limits on deeply nested user profiles; AV scanning/quarantining freshly written .lotp files; read-only Documents folder under a restricted account.","solutions":["Free space on the system drive and confirm Documents.SDKs.SDKs_Root is writable before calling Initial.","Shorten the SDK target path or enable long-path support to avoid the 260-char limit.","Temporarily disable/exclude the SDK folder in antivirus to rule out lock/quarantine.","Run the host process under an account with write permission to the Documents folder."],"exampleFix":"// before\nLib_AppSdk.Initial();\n\n// after\nstring root = Documents.SDKs.SDKs_Root;\nDirectory.CreateDirectory(root);\nif (new DriveInfo(Path.GetPathRoot(root)).AvailableFreeSpace < 50L * 1024 * 1024)\n{ /* not enough space; abort before Initial */ return; }\nLib_AppSdk.Initial();","handlingStrategy":"validation","validationCode":"string root = Documents.SDKs.SDKs_Root;\nDirectory.CreateDirectory(root);\nlong free = new DriveInfo(Path.GetPathRoot(root)).AvailableFreeSpace;\nif (free < 50L * 1024 * 1024) { /* not enough space; abort before Initial */ return; }\nLib_AppSdk.Initial();","typeGuard":"static bool WritableWithSpace(string dir, long minBytes)\n{\n    try\n    {\n        Directory.CreateDirectory(dir);\n        string probe = Path.Combine(dir, $\".wprobe_{Guid.NewGuid():N}\");\n        File.WriteAllText(probe, \"\");\n        File.Delete(probe);\n        return new DriveInfo(Path.GetPathRoot(dir)).AvailableFreeSpace >= minBytes;\n    }\n    catch { return false; }\n}","tryCatchPattern":null,"preventionTips":["Confirm Documents.SDKs.SDKs_Root is writable and has free space before Initial.","Enable long-path support or shorten the SDK target path to avoid the 260-char limit.","Exclude the SDK folder from antivirus to prevent lock/quarantine on written .lotp files.","Run the host under an account with write permission to the Documents folder."],"tags":["disk-io","sdk","disk-space","file-write","io"],"backgroundTag":null,"analyzedSha":"6f9a1bd471918f3310e6be4a6d7f42d0d6e467cf","analyzedAt":"2026-08-13T18:00:34.810Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}