Tewr / BlazorFileReader

Library for creating read-only file streams from file input elements or drop targets in Blazor.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReadLineAsync returns Null

thopdev opened this issue · comments

commented

Describe the bug
All lines read from files are null when build with --configuration Release

Code:
using var stream = await _fileReference.OpenReadAsync();
using var reader = new StreamReader(stream, Encoding.UTF8, true, 10000);
string line;
while ((line = await reader.ReadLineAsync()) != null)
{
yield return line;
}

line is always null when build with Release.

When building with Debug no problems occur.

commented

Sorry problem was at my end,
while ((line = await reader.ReadLineAsync()) != null)
this didn't work on release
i replaced it with

         var line = await reader.ReadLineAsync();
            while (line  != null)
            {
                var returnLine = line;
                line = await reader.ReadLineAsync();
                yield return returnLine;
                
            }

This did work