How do you read just part of a file as a stream in web api and do actions on this stream without taking the whole file in memory? NB: I don't want to save the file anywhere before reading - it's uploaded to a web api controller.
But what I really would like is the following pseudo code implemented:
foreach file in Request
{
using (var sr = new StreamReader(fileStream))
{
string firstLine = sr.ReadLine() ?? "";
if (firstLine contains the magic I need)
{
// would do something with this line,
// then scrap the stream and start reading the next file stream
continue;
}
}
}