OrchardCMS/OrchardCore · error · FileStoreException
The file ' ' does not exist.
Error message
The file '{srcPath}' does not exist. What it means
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.
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.
Example fix
// before
await store.CopyFileAsync("themes/img.png", "media/img.png"); // source missing
// after
if (await store.GetFileInfoAsync("themes/img.png") is null)
return; // or upload the source first
await store.CopyFileAsync("themes/img.png", "media/img.png"); Defensive patterns
Strategy: validation
Validate before calling
if (await store.GetFileInfoAsync(srcPath) is null)
throw new InvalidOperationException($"Source '{srcPath}' missing before copy"); Type guard
static async Task<bool> FileExistsAsync(IFileStore store, string path) => await store.GetFileInfoAsync(path) is not null;
Try / catch
try { await store.CopyFileAsync(srcPath, dstPath); }
catch (FileStoreException ex) when (ex.Message.Contains("does not exist"))
{
// source missing: skip, log, or upload first
} Prevention
- 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.
When it happens
Trigger: Calling CopyFileAsync(srcPath, dstPath) where srcPath does not exist: never uploaded, already deleted, or misspelled/wrong-cased.
Common situations: 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.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Cannot move file ' ' because it does not exist.
- Cannot create directory because the path
- Cannot create directory
- Cannot move file because the new path
- Cannot copy file because the destination path
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/b8667d5149c90008.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs:283
catch (FileStoreException)
{
throw;
}
catch (Exception ex)
{
throw new FileStoreException($"Cannot move file '{oldPath}' to '{newPath}'.", ex);
}
}
public Task CopyFileAsync(string srcPath, string dstPath)
{
try
{
var physicalSrcPath = GetPhysicalPath(srcPath);
if (!File.Exists(physicalSrcPath))
{
throw new FileStoreException($"The file '{srcPath}' does not exist.");
}
var physicalDstPath = GetPhysicalPath(dstPath);
if (File.Exists(physicalDstPath) || Directory.Exists(physicalDstPath))
{
throw new FileStoreException($"Cannot copy file because the destination path '{dstPath}' already exists.");
}
File.Copy(GetPhysicalPath(srcPath), GetPhysicalPath(dstPath));
return Task.CompletedTask;
}
catch (FileStoreException)
{
throw;
}
catch (Exception ex)View on GitHub (pinned to 4306c0717f)