{"record":{"id":"7906a0c18c7a5925","repo":"OrchardCMS/OrchardCore","slug":"cannot-get-file-stream-of-the-file-filestoreentry-path","errorCode":null,"errorMessage":"Cannot get file stream of the file '{fileStoreEntry.Path}'.","messagePattern":"Cannot get file stream of the file '(.+?)'\\.","errorType":"exception","errorClass":"FileStoreException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs","lineNumber":352,"sourceCode":"        try\n        {\n            var physicalPath = GetPhysicalPath(fileStoreEntry.Path);\n            if (!File.Exists(physicalPath))\n            {\n                throw new FileStoreException($\"Cannot get file stream because the file '{fileStoreEntry.Path}' does not exist.\");\n            }\n\n            var stream = File.OpenRead(physicalPath);\n\n            return Task.FromResult<Stream>(stream);\n        }\n        catch (FileStoreException)\n        {\n            throw;\n        }\n        catch (Exception ex)\n        {\n            throw new FileStoreException($\"Cannot get file stream of the file '{fileStoreEntry.Path}'.\", ex);\n        }\n    }\n\n    public async Task<string> CreateFileFromStreamAsync(string path, Stream inputStream, bool overwrite = false)\n    {\n        try\n        {\n            var physicalPath = GetPhysicalPath(path);\n\n            if (!overwrite && File.Exists(physicalPath))\n            {\n                throw new FileStoreException($\"Cannot create file '{path}' because it already exists.\");\n            }\n\n            if (Directory.Exists(physicalPath))\n            {\n                throw new FileStoreException($\"Cannot create file '{path}' because it already exists as a directory.\");\n            }","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.FileStorage.FileSystem/FileSystemStore.cs#L334-L370","documentation":"Generic catch-all of the IFileStoreEntry overload of GetFileStreamAsync: any non-FileStoreException error while resolving or opening fileStoreEntry.Path (permissions, IO errors, invalid path characters) is rethrown as FileStoreException with this message and the original exception as InnerException. It indicates an unexpected read failure rather than a missing file.","triggerScenarios":"GetFileStreamAsync(fileStoreEntry) where opening the physical file throws UnauthorizedAccessException, IOException (file locked), ArgumentException (invalid path), or GetPhysicalPath fails for the entry's path.","commonSituations":"Media folder permissions changed on the server; file held open by another request/upload; entry path corrupted by bad import; disk full or failing when reading from network storage.","solutions":["Log and inspect ex.InnerException for the underlying cause.","Fix filesystem permissions for the app identity on the store root.","Normalize/validate the entry's Path (invalid characters, length) before use.","Catch FileStoreException and surface a friendly error instead of a raw 500."],"exampleFix":"// before\nvar stream = await _fileStore.GetFileStreamAsync(entry);\n\n// after\ntry\n{\n    var stream = await _fileStore.GetFileStreamAsync(entry);\n}\ncatch (FileStoreException ex)\n{\n    _logger.LogError(ex.InnerException, \"Failed reading '{Path}'\", entry.Path);\n    return StatusCode(500);\n}","handlingStrategy":"try-catch","validationCode":"var fresh = await fileStore.GetFileInfoAsync(entry.Path);\nif (fresh is null || fresh.IsDirectory)\n{\n    throw new InvalidOperationException($\"'{entry.Path}' is not a readable file in the store.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    return await fileStore.GetFileStreamAsync(entry);\n}\ncatch (FileStoreException ex)\n{\n    logger.LogError(ex.InnerException, \"Unexpected error reading '{Path}': {Reason}\", entry.Path, ex.InnerException?.Message);\n    throw;\n}","preventionTips":["Log InnerException — the wrapper message hides the real IO/permission cause.","Verify store root permissions after deployments or server migration.","Validate entry paths on import/ingest so corrupt paths fail early.","Monitor disk health on network-backed storage volumes."],"tags":["file-storage","file-read-failed","io"],"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-16T04:17:20.429Z"}