OrchardCMS/OrchardCore · error · FileStoreException
Cannot copy file ' ' because it does not exist.
Error message
Cannot copy file '{srcPath}' because it does not exist. What it means
CopyFileAsync checks that the source blob exists before copying and throws FileStoreException naming the source path when it does not. Blob references are lazy in the Azure SDK, so a missing file only surfaces at this explicit ExistsAsync check.
Solutions
- Verify the source path with FileExistsAsync before copying and handle the miss gracefully.
- Fix the stored path/reference that points to a nonexistent blob.
- Check container name and BasePath configuration if all copies fail.
- Match the blob name exactly as stored, including casing.
Example fix
// before
await _fileStore.CopyFileAsync(srcPath, dstPath);
// after
if (!await _fileStore.FileExistsAsync(srcPath))
{
_logger.LogWarning("Source file {Src} not found; skipping copy", srcPath);
return;
}
await _fileStore.CopyFileAsync(srcPath, dstPath); Defensive patterns
Strategy: validation
Validate before calling
if (!await _fileStore.FileExistsAsync(srcPath))
{
_logger.LogWarning("Source {Src} missing; skipping copy", srcPath);
return;
}
await _fileStore.CopyFileAsync(srcPath, dstPath); Try / catch
try
{
await _fileStore.CopyFileAsync(srcPath, dstPath);
}
catch (FileStoreException ex) when (ex.Message.Contains("does not exist"))
{
_logger.LogWarning("Copy skipped: source {Src} not found", srcPath);
} Prevention
- Verify stored file references against the store before use (detect orphans).
- Blob paths are case-sensitive; preserve exact casing from the store.
- Double-check container and BasePath settings when many copies fail.
- Handle external deletions gracefully in media cleanup jobs.
When it happens
Trigger: Calling IFileStore.CopyFileAsync(srcPath, dstPath) when no blob exists under the source path (wrong path, file deleted externally, or typo including case, since blob names are case-sensitive).
Common situations: Media items referencing files deleted outside the app; stale database records pointing at renamed files; case-mismatched paths; wrong container/base prefix configuration.
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 copy file ' ' because it does not exist.
- Cannot delete the root directory.
- Cannot delete directory
- Cannot move file ' ' to ' '.
- The values for and must not be the same.
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/6b4dd7d6deb4b380.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.FileStorage.AzureBlob/BlobFileStore.cs:593
throw new FileStoreException($"Cannot move file '{oldPath}' to '{newPath}'.", ex);
}
}
public async Task CopyFileAsync(string srcPath, string dstPath)
{
try
{
if (srcPath == dstPath)
{
throw new ArgumentException($"The values for {nameof(srcPath)} and {nameof(dstPath)} must not be the same.");
}
var oldBlob = GetBlobReference(srcPath);
var newBlob = GetBlobReference(dstPath);
if (!await oldBlob.ExistsAsync())
{
throw new FileStoreException($"Cannot copy file '{srcPath}' because it does not exist.");
}
if (await newBlob.ExistsAsync())
{
throw new FileStoreException($"Cannot copy file '{srcPath}' because a file already exists in the new path '{dstPath}'.");
}
await newBlob.StartCopyFromUriAsync(oldBlob.Uri);
await Task.Delay(250);
var properties = await newBlob.GetPropertiesAsync();
while (properties.Value.CopyStatus == CopyStatus.Pending)
{
await Task.Delay(250);
// Need to fetch properties or CopyStatus will never update.
properties = await newBlob.GetPropertiesAsync();View on GitHub (pinned to 4306c0717f)