System.IO.Abstractions icon indicating copy to clipboard operation
System.IO.Abstractions copied to clipboard

IFile.Create has different return type than File.Create

Open Heldenkrieger01 opened this issue 4 years ago • 3 comments

Describe the bug The IFile.Create() method returns a Stream, but the "original" File.Create() returns a FileStream. This is important, because the FileStream contains the Name-property with the files name.

Expected behavior IFile.Create() returns a FileStream.

Heldenkrieger01 avatar Dec 14 '21 10:12 Heldenkrieger01

This is more or less by design, because FileStream relies on the real file system.

We could return a custom subclass of Stream that adds the Name property.

What do you think about this @HeldenKrieger01?

fgreinacher avatar Dec 17 '21 12:12 fgreinacher

That would be great, especially for people like me, that move to Abstractions with existing code.

Heldenkrieger01 avatar Dec 23 '21 15:12 Heldenkrieger01

Cool, so let's make this as ready and discuss details in a PR, once somebody finds the time to work on this 👍

fgreinacher avatar Jan 06 '22 12:01 fgreinacher

I think this issue can be closed, as the FileSystemStream was implemented in #906 ... Do you agree, @Heldenkrieger01 ?

vbreuss avatar Apr 16 '23 17:04 vbreuss

I'm closing this. Feel free to reopen if needed!

fgreinacher avatar Apr 19 '23 17:04 fgreinacher