{"record":{"id":"ee008913c60b29ec","repo":"files-community/Files","slug":"failed-to-create-file-remotepath","errorCode":null,"errorMessage":"Failed to create file {remotePath}.","messagePattern":"Failed to create file (.+?)\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs","lineNumber":228,"sourceCode":"\t\t\t\t}\n\t\t\t\twhile (result is FtpStatus.Skipped && ++attempt < 1024 && options == CreationCollisionOption.GenerateUniqueName);\n\n\t\t\t\tif (result is FtpStatus.Success)\n\t\t\t\t{\n\t\t\t\t\tvar file = new FtpStorageFile(new StorageFileWithPath(null, $\"{Path}/{finalName}\"));\n\t\t\t\t\t((IPasswordProtectedItem)file).CopyFrom(this);\n\t\t\t\t\treturn file;\n\t\t\t\t}\n\n\t\t\t\tif (result is FtpStatus.Skipped)\n\t\t\t\t{\n\t\t\t\t\tif (options is CreationCollisionOption.FailIfExists)\n\t\t\t\t\t\tthrow new FileAlreadyExistsException(desiredName);\n\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\tthrow new IOException($\"Failed to create file {remotePath}.\");\n\t\t\t}, ((IPasswordProtectedItem)this).RetryWithCredentialsAsync));\n\t\t}\n\n\t\tpublic override IAsyncOperation<BaseStorageFolder> CreateFolderAsync(string desiredName)\n\t\t\t=> CreateFolderAsync(desiredName, CreationCollisionOption.FailIfExists);\n\t\tpublic override IAsyncOperation<BaseStorageFolder> CreateFolderAsync(string desiredName, CreationCollisionOption options)\n\t\t{\n\t\t\treturn AsyncInfo.Run((cancellationToken) => SafetyExtensions.Wrap<BaseStorageFolder>(async () =>\n\t\t\t{\n\t\t\t\tusing var ftpClient = GetFtpClient();\n\t\t\t\tif (!await ftpClient.EnsureConnectedAsync())\n\t\t\t\t{\n\t\t\t\t\tthrow new IOException($\"Failed to connect to FTP server.\");\n\t\t\t\t}\n\n\t\t\t\tstring fileName = $\"{FtpPath}/{desiredName}\";\n\t\t\t\tif (await ftpClient.DirectoryExists(fileName))\n\t\t\t\t{","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/files-community/Files/blob/68c68a58d4d6a5f7197e07c8fff85cfd4279c78b/src/Files.App/Utils/Storage/StorageItems/FtpStorageFolder.cs#L210-L246","documentation":"Thrown by the WinRT-facing FtpStorageFolder.CreateFileAsync (Files.App/Utils) when UploadStream returns a status that is neither Success nor Skipped - i.e. FtpStatus.Failed - after the GenerateUniqueName retry loop and the FailIfExists branch have both been ruled out. The upload could not complete for a server-side reason.","triggerScenarios":"UploadStream returning FtpStatus.Failed during CreateFileAsync after the unique-name loop exhausted (or collision option was OpenIfExists/ReplaceExisting). Permission denied on the folder, missing parent directory, quota exceeded, or a dropped data connection.","commonSituations":"Read-only FTP target; nested path whose parent was never created; quota hit; unstable network breaking PASV data channel mid-upload; antivirus quarantining the uploaded file on the server.","solutions":["Read ftpClient.LastReply for the underlying 4xx/5xx reply and report the specific code.","Confirm the target folder exists and the account has write permission.","Retry with backoff on transient failures (network drops are common).","If quota is the cause, free space on the server or use a different account.","Wrap in try/catch and present a user-readable failure with the remote path."],"exampleFix":"// before\nthrow new IOException($\"Failed to create file {remotePath}.\");\n\n// after\nvar reply = ftpClient.LastReply;\nthrow new IOException($\"Failed to create file {remotePath}: {(int)reply?.Code} {reply?.Message}\");","handlingStrategy":"try-catch","validationCode":"// Verify write permission and parent existence before the upload.\nif (!await ftpClient.DirectoryExists(FtpPath, ct))\n    throw new IOException(\"Parent folder missing; cannot create file.\");","typeGuard":null,"tryCatchPattern":"try { return await folder.CreateFileAsync(name, options); }\ncatch (IOException ex) when (ex.Message.Contains(\"Failed to create file\"))\n{ var reply = ftpClient.LastReply; /* log and report specific code */ throw; }","preventionTips":["Capture ftpClient.LastReply for the underlying failure code.","Confirm write permission and quota on the target folder.","Retry with backoff on transient network failures."],"tags":["ftp","storage","file-creation","network"],"backgroundTag":null,"analyzedSha":"68c68a58d4d6a5f7197e07c8fff85cfd4279c78b","analyzedAt":"2026-08-13T10:34:54.614Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}