uHttpSharp icon indicating copy to clipboard operation
uHttpSharp copied to clipboard

Locked files after download

Open ficiyoki opened this issue 7 years ago • 2 comments

I have a problem were once files are downloaded (e.g using the FileHandler) the files remain locked because the ContentStream of the HttpResponse is never closed/disposed. Is there a way around this? I feel the file should be released once the transfer is complete.

ficiyoki avatar Sep 05 '18 16:09 ficiyoki

Hi @ficiyoki, this repository is no longer maintained, you're welcome to create a pull request and I'll merge it if everything looks good.

shanielh avatar Sep 06 '18 14:09 shanielh

Just close the stream after the content is written.

    public async Task WriteBody(StreamWriter writer) {
        ContentStream.Position = 0;
        await writer.FlushAsync().ConfigureAwait(false);
        await ContentStream.CopyToAsync(writer.BaseStream).ConfigureAwait(false);
        //close the stream

--> ContentStream.Close(); }

czesiu20 avatar Apr 16 '19 10:04 czesiu20