{"record":{"id":"b8667d5149c90008","repo":"OrchardCMS/OrchardCore","slug":"the-file-srcpath-does-not-exist","errorCode":null,"errorMessage":"The file '{srcPath}' does not exist.","messagePattern":"The file '(.+?)' does not exist\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs","lineNumber":283,"sourceCode":"        catch (FileStoreException)\n        {\n            throw;\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot move file '{oldPath}' to '{newPath}'.\", ex);\n        }\n    }\n\n    public Task CopyFileAsync(string srcPath, string dstPath)\n    {\n        try\n        {\n            var physicalSrcPath = GetPhysicalPath(srcPath);\n\n            if (!File.Exists(physicalSrcPath))\n            {\n                throw new FileStoreException($\"The file '{srcPath}' does not exist.\");\n            }\n\n            var physicalDstPath = GetPhysicalPath(dstPath);\n\n            if (File.Exists(physicalDstPath) || Directory.Exists(physicalDstPath))\n            {\n                throw new FileStoreException($\"Cannot copy file because the destination path '{dstPath}' already exists.\");\n            }\n\n            File.Copy(GetPhysicalPath(srcPath), GetPhysicalPath(dstPath));\n\n            return Task.CompletedTask;\n        }\n        catch (FileStoreException)\n        {\n            throw;\n        }\n        catch (Exception ex)","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs#L265-L301","documentation":"Pre-flight check in FileSystemStore.CopyFileAsync: File.Exists returned false for the physical source path. The copy is rejected before any I/O happens because the source file is not present at srcPath in the store.","triggerScenarios":"Calling CopyFileAsync(srcPath, dstPath) where srcPath does not exist: never uploaded, already deleted, or misspelled/wrong-cased.","commonSituations":"Duplicating media items using a stale source path; copying from a tenant-local path while code runs in a different tenant shell; recipe/import steps referencing files that were not deployed.","solutions":["Check await store.GetFileInfoAsync(srcPath) is not null before copying.","Correct the srcPath value (casing, extension, tenant scope).","Ensure the source is created/uploaded before the copy step runs."],"exampleFix":"// before\nawait store.CopyFileAsync(\"themes/img.png\", \"media/img.png\"); // source missing\n// after\nif (await store.GetFileInfoAsync(\"themes/img.png\") is null)\n    return; // or upload the source first\nawait store.CopyFileAsync(\"themes/img.png\", \"media/img.png\");","handlingStrategy":"validation","validationCode":"if (await store.GetFileInfoAsync(srcPath) is null)\n    throw new InvalidOperationException($\"Source '{srcPath}' missing before copy\");","typeGuard":"static async Task<bool> FileExistsAsync(IFileStore store, string path) => await store.GetFileInfoAsync(path) is not null;","tryCatchPattern":"try { await store.CopyFileAsync(srcPath, dstPath); }\ncatch (FileStoreException ex) when (ex.Message.Contains(\"does not exist\"))\n{\n    // source missing: skip, log, or upload first\n}","preventionTips":["Verify the source exists in the same tenant/shell you are running in.","Make import/recipe copy steps tolerate missing sources.","Use canonical, tested constants for known source paths."],"tags":["filesystem","file-store","file-not-found"],"backgroundTag":"file-not-found","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"}