{"record":{"id":"0f0ccdc193eabe6f","repo":"EllanJiang/GameFramework","slug":"save-as-file-0-to-1-from-file-system-2-error","errorCode":null,"errorMessage":"Save as file '{0}' to '{1}' from file system '{2}' error.","messagePattern":"Save as file '(.+?)' to '(.+?)' from file system '(.+?)' error\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceChecker.cs","lineNumber":154,"sourceCode":"                    CheckInfo ci = checkInfo.Value;\n                    ci.RefreshStatus(m_CurrentVariant, m_IgnoreOtherVariant);\n                    if (ci.Status == CheckInfo.CheckStatus.StorageInReadOnly)\n                    {\n                        m_ResourceManager.m_ResourceInfos.Add(ci.ResourceName, new ResourceInfo(ci.ResourceName, ci.FileSystemName, ci.LoadType, ci.Length, ci.HashCode, ci.CompressedLength, true, true));\n                    }\n                    else if (ci.Status == CheckInfo.CheckStatus.StorageInReadWrite)\n                    {\n                        if (ci.NeedMoveToDisk || ci.NeedMoveToFileSystem)\n                        {\n                            movedCount++;\n                            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                            }","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceChecker.cs#L136-L172","documentation":"During RefreshCheckInfoStatus, resources stored in a read-write binary file system that must be moved back to disk are extracted with IFileSystem.SaveAsFile. When SaveAsFile returns false the framework cannot materialize the resource file at resourcePath and throws this formatted GameFrameworkException naming the resource, target path and file system full path.","triggerScenarios":"RefreshCheckInfoStatus processes a CheckInfo with NeedMoveToDisk=true and the underlying file system's SaveAsFile fails — typically because the destination disk file already exists or the file system lacks the resource entry, or disk I/O fails.","commonSituations":"Leftover stale files in ReadWritePath from a previous build/version; corrupted read-write file system (.dat) after a crashed update; running out of disk space on device; mismatched version lists after upgrading the resource pipeline.","solutions":["Delete stale files with the same name in ReadWritePath (or clear ReadWritePath) and re-run the resource update so SaveAsFile has no conflicting target.","Regenerate/repair the read-write file system: if m_ReadWriteFileSystems data is corrupted, remove the read-write directory and redownload resources.","Check free disk space and write permissions for ReadWritePath on the device.","Verify the read-write version list and file system were produced by the same resource build."],"exampleFix":"// before (stale file blocks SaveAsFile)\nm_ResourceComponent.CheckResources();\n\n// after: clean conflicting stale files first\nstring stalePath = Utility.Path.GetRegularPath(Path.Combine(readWritePath, resourceFullName));\nif (File.Exists(stalePath)) File.Delete(stalePath);\nm_ResourceComponent.CheckResources();","handlingStrategy":"try-catch","validationCode":"string target = Utility.Path.GetRegularPath(Path.Combine(readWritePath, resourceFullName));\nif (File.Exists(target)) File.Delete(target); // remove stale conflict before check\nlong freeSpace = new DriveInfo(Path.GetPathRoot(readWritePath)).AvailableFreeSpace;\nif (freeSpace < 64L * 1024 * 1024) Debug.LogWarning(\"Low disk space before resource check\");","typeGuard":null,"tryCatchPattern":"try { m_ResourceComponent.CheckResources(); }\ncatch (GameFrameworkException ex) when (ex.Message.StartsWith(\"Save as file\"))\n{\n    Debug.LogError($\"Move-to-disk failed, clearing read-write area: {ex.Message}\");\n    if (Directory.Exists(readWritePath)) Directory.Delete(readWritePath, true);\n    // restart the update flow\n}","preventionTips":["Clean leftover loose files in ReadWritePath before updating after a version change.","Monitor free disk space before starting resource updates on mobile.","Never manually edit or copy files into the read-write area while a check is running."],"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"}