C#C
C#4y ago
2 replies
Kosta

Streaming a csv file to a console app with minimal api-How?

Hey Guys got this methode:
    public string MakeHttpCall()
    {
        var watch = new Stopwatch();
        Stopwatch.StartNew();
        using (var reader = new StreamReader(@"C:\Users\kosta\source\repos\gRPCDemoUsingNET6\gRPCDemoUsingNET6\Data"))
        {
            while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();
                var values = line.Split(';');

            }
            return string.Empty;
        }
    }
}

And this one in the Ui:
var client = new HttpClient();
await using Stream stream =
    await client.GetStreamAsync("http://localhost:5276");
var lines =
    await JsonSerializer.DeserializeAsync<List<string>>(stream);
foreach (var line in lines)
{
    Console.WriteLine(line);

}

I want to stream the csv file to the ui, which happens here
 while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();
                var values = line.Split(';');

            }

Unsure how to do that
Was this page helpful?