{"record":{"id":"e81ab678174292be","repo":"EllanJiang/GameFramework","slug":"write-resource-0-to-file-system-1-error","errorCode":null,"errorMessage":"Write resource '{0}' to file system '{1}' error.","messagePattern":"Write resource '(.+?)' to file system '(.+?)' error\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceChecker.cs","lineNumber":165,"sourceCode":"                            string resourceFullName = ci.ResourceName.FullName;\n                            string resourcePath = Utility.Path.GetRegularPath(Path.Combine(m_ResourceManager.m_ReadWritePath, resourceFullName));\n                            if (ci.NeedMoveToDisk)\n                            {\n                                IFileSystem fileSystem = m_ResourceManager.GetFileSystem(ci.ReadWriteFileSystemName, false);\n                                if (!fileSystem.SaveAsFile(resourceFullName, resourcePath))\n                                {\n                                    throw new GameFrameworkException(Utility.Text.Format(\"Save as file '{0}' to '{1}' from file system '{2}' error.\", resourceFullName, resourcePath, fileSystem.FullPath));\n                                }\n\n                                fileSystem.DeleteFile(resourceFullName);\n                            }\n\n                            if (ci.NeedMoveToFileSystem)\n                            {\n                                IFileSystem fileSystem = m_ResourceManager.GetFileSystem(ci.FileSystemName, false);\n                                if (!fileSystem.WriteFile(resourceFullName, resourcePath))\n                                {\n                                    throw new GameFrameworkException(Utility.Text.Format(\"Write resource '{0}' to file system '{1}' error.\", resourceFullName, fileSystem.FullPath));\n                                }\n\n                                if (File.Exists(resourcePath))\n                                {\n                                    File.Delete(resourcePath);\n                                }\n                            }\n                        }\n\n                        m_ResourceManager.m_ResourceInfos.Add(ci.ResourceName, new ResourceInfo(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, ci.CompressedLength, false, true));\n                        m_ResourceManager.m_ReadWriteResourceInfos.Add(ci.ResourceName, new ReadWriteResourceInfo(ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode));\n                    }\n                    else if (ci.Status == CheckInfo.CheckStatus.Update)\n                    {\n                        m_ResourceManager.m_ResourceInfos.Add(ci.ResourceName, new ResourceInfo(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, ci.CompressedLength, false, false));\n                        updateCount++;\n                        updateTotalLength += ci.Length;\n                        updateTotalCompressedLength += ci.CompressedLength;","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceChecker.cs#L147-L183","documentation":"In the opposite move direction, when a CheckInfo has NeedMoveToFileSystem=true, RefreshCheckInfoStatus imports a loose disk file into a binary read-write file system via IFileSystem.WriteFile. If WriteFile returns false, the file could not be stored in the file system and this GameFrameworkException is thrown with the resource name and file system path.","triggerScenarios":"RefreshCheckInfoStatus processes a CheckInfo with NeedMoveToFileSystem=true and fileSystem.WriteFile(resourceFullName, resourcePath) fails — the file system is corrupted, full, or cannot read the source disk file at resourcePath.","commonSituations":"Read-write file system (.dat) corrupted after abnormal app termination; disk quota/full storage on mobile; source file deleted or locked between the version-list check and the move; mixing file systems from different resource versions.","solutions":["Delete/repair the corrupted read-write file system (remove ReadWritePath contents) and let the update re-download everything.","Confirm sufficient free storage on the device before running the update.","Ensure the read-write version list and the actual files on disk come from the same resource version.","Retry the whole CheckResources/UpdateResource flow once the environment is clean."],"exampleFix":"// before\n// corrupted .dat file system -> WriteFile returns false -> throws\n\n// after: reset the read-write area\nif (Directory.Exists(readWritePath)) Directory.Delete(readWritePath, true);\nDirectory.CreateDirectory(readWritePath);\nm_ResourceComponent.UpdateResourceAsync();","handlingStrategy":"try-catch","validationCode":"if (new DriveInfo(Path.GetPathRoot(readWritePath)).AvailableFreeSpace < 128L * 1024 * 1024)\n    Debug.LogWarning(\"Insufficient storage for file-system move\");","typeGuard":null,"tryCatchPattern":"try { m_ResourceComponent.CheckResources(); }\ncatch (GameFrameworkException ex) when (ex.Message.StartsWith(\"Write resource\"))\n{\n    Debug.LogError($\"File system write failed, resetting read-write data: {ex.Message}\");\n    if (Directory.Exists(readWritePath)) Directory.Delete(readWritePath, true);\n    // re-run update to rebuild file systems\n}","preventionTips":["Treat the read-write area as disposable: on corruption, delete and redownload.","Check storage headroom before large updates.","Avoid killing the app during the move phase to reduce file-system corruption."],"tags":["gameframework","filesystem","io","resource-update"],"backgroundTag":"file-write-failed","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}