OrchardCMS/OrchardCore · error · FileStoreException
Cannot get files with path
Error message
Cannot get files with path '{path}'. What it means
FileSystemStore.GetFilesAsync lists only files under a path (with optional subdirectory search in some flows) and wraps enumeration exceptions in a FileStoreException with this message. It is the file-focused variant of GetDirectoryContentAsync and fails for the same I/O reasons.
Solutions
- Inspect the InnerException to identify the concrete System.IO error and address it (permissions, path validity, existence).
- Ensure read permissions on all levels of the storage root subtree.
- Validate/shorten the path if MAX_PATH or invalid characters are implicated.
- Check the folder was not deleted or renamed by a concurrent process before listing.
Example fix
// before
var files = fileStore.GetFilesAsync("media");
// after
try
{
var files = fileStore.GetFilesAsync("media");
}
catch (FileStoreException ex)
{
logger.LogError(ex.InnerException, "Failed to list files in media");
} Defensive patterns
Strategy: try-catch
Validate before calling
if (await fileStore.GetDirectoryInfoAsync(path) == null)
{
return AsyncEnumerable.Empty<IFileStoreEntry>();
} Try / catch
try
{
await foreach (var f in fileStore.GetFilesAsync(path)) { /* ... */ }
}
catch (FileStoreException ex) when (ex.InnerException is UnauthorizedAccessException)
{
logger.LogWarning("Access denied listing files in {Path}", path);
} Prevention
- Verify list/read permissions across subfolders
- Keep paths within MAX_PATH limits on Windows
- Check folder existence/renames before listing
- Exclude store folders from AV/indexer interference
When it happens
Trigger: Calling IFileStore.GetFilesAsync(path) when the underlying file enumeration throws: access denied, path invalid or too long, or the directory disappears mid-enumeration.
Common situations: Media listing pages after the folder backing the store was moved; restrictive ACLs on subfolders; long-path issues on Windows; file locks from other services during listing.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- Cannot get directories with path
- Cannot get directory content with path
- Cannot get directory info with path
- Cannot get file info with path
- Cannot copy file ' ' to ' '.
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/26b6dd90082d73ea.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs:138
{
return Array.Empty<IFileStoreEntry>().ToAsyncEnumerable();
}
var results = Directory
.GetFiles(physicalPath, "*", SearchOption.TopDirectoryOnly)
.Select(f =>
{
var fileSystemInfo = new PhysicalFileInfo(new FileInfo(f));
var fileRelativePath = f[_fileSystemPath.Length..];
var filePath = this.NormalizePath(fileRelativePath);
return (IFileStoreEntry)new FileSystemStoreEntry(filePath, fileSystemInfo);
});
return results.ToAsyncEnumerable();
}
catch (Exception ex)
{
throw new FileStoreException($"Cannot get files with path '{path}'.", ex);
}
}
public IAsyncEnumerable<IFileStoreEntry> GetDirectoriesAsync(string path = null)
{
try
{
var physicalPath = GetPhysicalPath(path);
if (!Directory.Exists(physicalPath))
{
return Array.Empty<IFileStoreEntry>().ToAsyncEnumerable();
}
var results = Directory
.GetDirectories(physicalPath, "*", SearchOption.TopDirectoryOnly)
.Select(f =>
{View on GitHub (pinned to 4306c0717f)