{"record":{"id":"1beacd1f8bc35bfc","repo":"OrchardCMS/OrchardCore","slug":"cannot-copy-file-srcpath-to-dstpath","errorCode":null,"errorMessage":"Cannot copy file '{srcPath}' to '{dstPath}'.","messagePattern":"Cannot copy file '(.+?)' to '(.+?)'\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs","lineNumber":625,"sourceCode":"            {\n                await Task.Delay(250);\n\n                // Need to fetch properties or CopyStatus will never update.\n                properties = await newBlob.GetPropertiesAsync();\n            }\n\n            if (properties.Value.CopyStatus != CopyStatus.Success)\n            {\n                throw new FileStoreException($\"Error while copying file '{srcPath}'; copy operation failed with status {properties.Value.CopyStatus} and description {properties.Value.CopyStatusDescription}.\");\n            }\n        }\n        catch (FileStoreException)\n        {\n            throw;\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot copy file '{srcPath}' to '{dstPath}'.\", ex);\n        }\n    }\n\n    public async Task<Stream> GetFileStreamAsync(string path)\n    {\n        try\n        {\n            var blob = GetBlobReference(path);\n\n            if (!await blob.ExistsAsync())\n            {\n                throw new FileStoreException($\"Cannot get file stream because the file '{path}' does not exist.\");\n            }\n\n            return (await blob.DownloadAsync()).Value.Content;\n        }\n        catch (FileStoreException)\n        {","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs#L607-L643","documentation":"BlobFileStore.CopyFileAsync wraps any non-FileStoreException failure from the Azure Blob Storage SDK copy operation in a FileStoreException with this message. It signals the blob copy itself failed after argument validation (e.g. source blob missing or a storage service error). The inner exception carries the underlying Azure storage error.","triggerScenarios":"Calling IFileStore.CopyFileAsync(srcPath, dstPath) when the source blob does not exist (RequestFailedException 404), when the destination path is invalid/contains illegal characters, or when the Azure Storage service rejects the StartCopy/Upload operation (quota, auth, throttling).","commonSituations":"Copies between media folders where the source was deleted or renamed by another request; bad storage account credentials or connection string; blob name characters invalid to Azure; storage service outages or throttling under load.","solutions":["Check the InnerException (RequestFailedException Status) to see the real Azure error: 404 means the source path is wrong, 403 means auth failed, 409/503 means throttling or conflict.","Verify the source path exists with fileStore.GetFileInfoAsync(srcPath) before copying.","Confirm the Azure Blob Storage connection string and container are correctly configured and the account is reachable.","Ensure paths use forward slashes and contain only valid blob-name characters (no illegal Windows chars)."],"exampleFix":"// before\nawait fileStore.CopyFileAsync(\"media/old.jpg\", \"media/new.jpg\");\n// after\nif (await fileStore.GetFileInfoAsync(\"media/old.jpg\") == null)\n{\n    throw new InvalidOperationException(\"Source file does not exist.\");\n}\nawait fileStore.CopyFileAsync(\"media/old.jpg\", \"media/new.jpg\");","handlingStrategy":"try-catch","validationCode":"var src = await fileStore.GetFileInfoAsync(srcPath);\nif (src == null)\n{\n    throw new InvalidOperationException($\"Source '{srcPath}' does not exist.\");\n}\nif (await fileStore.GetFileInfoAsync(dstPath) != null)\n{\n    throw new InvalidOperationException($\"Destination '{dstPath}' already exists.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await fileStore.CopyFileAsync(srcPath, dstPath);\n}\ncatch (FileStoreException ex)\n{\n    logger.LogError(ex.InnerException, \"Copy failed from {Src} to {Dst}\", srcPath, dstPath);\n}","preventionTips":["Check source existence before copying","Verify Azure Storage credentials and connectivity","Use only valid blob-name characters in paths","Retry transient (5xx/429) storage errors with backoff"],"tags":["azure-blob-storage","file-storage","io"],"backgroundTag":"file-read-failed","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}