StreamReader is always EndOfStream=true even before reading
So this code works when I run locally with a file name hard coded in. When I instead download the the file and load it into a FileStream, it's always at EndOfStream. Am I doing something wrong?
Here's what the code would look like in the way it's NOT working:
8 Replies
is the
CopyToAsync
forcing it to the EOS?
Looks like that might have been it. I closed the FileStream after copying, then opened a new FileStream to read the newly created file
Seems a bit redundant, but I guess necessary?copying implies reading the whole stream, so it makes sense it would be at the end afterwards
you can probably seek it back to the beginning instead of closing and reopening the file
Yeah make sense. Thanks
also since you're using await, use it on the getasync as well.
and
why? I don't need to wait for that to complete until the copy
what if your request failed?
among other issues that can happen in between
ok
there is 2 separate awaits there
one for the request header
the other for the content