Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

File.Open doesn't set FileStream.Name #494

Open
ghost opened this issue Sep 12, 2018 · 4 comments
Open

File.Open doesn't set FileStream.Name #494

ghost opened this issue Sep 12, 2018 · 4 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Sep 12, 2018

If I call File.Open the returned FileStream object has it's Name property set to '[Unknown]'. With the .NET variant of File.Open this property is set to the file path.

@Yomodo
Copy link
Collaborator

Yomodo commented Sep 12, 2018

A possible workaround for this issue, here #438.

@ghost
Copy link
Author

ghost commented Sep 12, 2018

OK, sorry for not finding this before writing.

I've searched a bit through the .NET and AlphaFS code and I think this is caused by AlphaFS always creating the FileStream from handle and not from path. If the FileStream is created from handle the Name property is set to null (https://referencesource.microsoft.com/#mscorlib/system/io/filestream.cs,c49450a04f720cdd).

Maybe this can be worked around somehow?

@alphaleonis
Copy link
Owner

I think the only way to work around it is if we'd use reflection to set the _fileName field of the FileStream instance after creating it. It could be a viable option actually, since this is a quite annoying "bug". What do you think @Yomodo? (We would just need to create tests for this to ensure it doesn't break with new .NET versions, but I find it unlikely that they'd change this).

@Yomodo
Copy link
Collaborator

Yomodo commented Sep 20, 2018

@alphaleonis Sounds like a plan!

@alphaleonis alphaleonis added this to the vNext milestone Oct 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants