Skip to content

File.ReadAllBytes* should support non-seekable files #58383

@adamsitnik

Description

@adamsitnik

As of today, File.WriteAllBytes* APIs support non-seekable files, but File.ReadAllBytes* don't.

The following call to FileStream.Length is going to throw:

The funny thing is that we already almost support it:

else if (fileLength == 0)
{
#if !MS_IO_REDIST
// Some file systems (e.g. procfs on Linux) return 0 for length even when there's content.
// Thus we need to assume 0 doesn't mean empty.
return ReadAllBytesUnknownLength(fs);
#endif
}

We need:

  • test that shows the broken scenario
  • a fix

Metadata

Metadata

Labels

area-System.IOhelp wanted[up-for-grabs] Good issue for external contributors

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions