KristofferStrube / Blazor.FileSystemAccess

A Blazor wrapper for the File System Access browser API.
https://kristofferstrube.github.io/Blazor.FileSystemAccess/
MIT License
327 stars 39 forks source link

How to get a StreamReader #50

Closed igngi closed 9 months ago

igngi commented 10 months ago

Hi, I'm trying to use FileSystemAccess to read a big csv file and I need a StreamReader. I saw that I can get a ReadableStream using GetFileStream but I can't figure out how to convert that into a StreamReader.

Any help will be appreciated.

Thanks!

KristofferStrube commented 10 months ago

Hey @igngi, I recommend that you simply use the native StreamReader implementation from the Blazor. Streams library, where the ReadableStream implementation lives.

I recommend this because the ReadableStream is very limited meaning you can't seek and you can't invoke synchronous stream methods. I have an open issue here that also touches on what we need to get to a place where it would be easier for the ReadableStream implementation to be consumable by the .NET Standard implementation of a StreamReader: https://github.com/KristofferStrube/Blazor.Streams/issues/3

I also recommend that you explore the demo pages related to ReadableStream from the Blazor.Streams library to see what use cases fit your needs: https://kristofferstrube.github.io/Blazor.Streams/