{"record":{"id":"26b6dd90082d73ea","repo":"OrchardCMS/OrchardCore","slug":"cannot-get-files-with-path-path","errorCode":null,"errorMessage":"Cannot get files with path '{path}'.","messagePattern":"Cannot get files with path '(.+?)'\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs","lineNumber":138,"sourceCode":"            {\n                return Array.Empty<IFileStoreEntry>().ToAsyncEnumerable();\n            }\n\n            var results = Directory\n                .GetFiles(physicalPath, \"*\", SearchOption.TopDirectoryOnly)\n                .Select(f =>\n                {\n                    var fileSystemInfo = new PhysicalFileInfo(new FileInfo(f));\n                    var fileRelativePath = f[_fileSystemPath.Length..];\n                    var filePath = this.NormalizePath(fileRelativePath);\n                    return (IFileStoreEntry)new FileSystemStoreEntry(filePath, fileSystemInfo);\n                });\n\n            return results.ToAsyncEnumerable();\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot get files with path '{path}'.\", ex);\n        }\n    }\n\n    public IAsyncEnumerable<IFileStoreEntry> GetDirectoriesAsync(string path = null)\n    {\n        try\n        {\n            var physicalPath = GetPhysicalPath(path);\n\n            if (!Directory.Exists(physicalPath))\n            {\n                return Array.Empty<IFileStoreEntry>().ToAsyncEnumerable();\n            }\n\n            var results = Directory\n                .GetDirectories(physicalPath, \"*\", SearchOption.TopDirectoryOnly)\n                .Select(f =>\n                {","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs#L120-L156","documentation":"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.","triggerScenarios":"Calling IFileStore.GetFilesAsync(path) when the underlying file enumeration throws: access denied, path invalid or too long, or the directory disappears mid-enumeration.","commonSituations":"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.","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."],"exampleFix":"// before\nvar files = fileStore.GetFilesAsync(\"media\");\n// after\ntry\n{\n    var files = fileStore.GetFilesAsync(\"media\");\n}\ncatch (FileStoreException ex)\n{\n    logger.LogError(ex.InnerException, \"Failed to list files in media\");\n}","handlingStrategy":"try-catch","validationCode":"if (await fileStore.GetDirectoryInfoAsync(path) == null)\n{\n    return AsyncEnumerable.Empty<IFileStoreEntry>();\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    await foreach (var f in fileStore.GetFilesAsync(path)) { /* ... */ }\n}\ncatch (FileStoreException ex) when (ex.InnerException is UnauthorizedAccessException)\n{\n    logger.LogWarning(\"Access denied listing files in {Path}\", path);\n}","preventionTips":["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"],"tags":["file-system","io","enumeration"],"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-23T08:17:48.524Z"}