Quantcast
Channel: sharpcompress Discussions Rss Feed
Viewing all articles
Browse latest Browse all 239

New Post: Can you read entries concurrently?

$
0
0
Hi,
I was trying to read entries concurrently and then save the output as a file, however the output image is corrupted.

private async Task<string> SaveFileAsyncReadingSync(Stream streamSource, StorageFolder destinationStorageFolder, string destinationFileName)
    {
        var file = await destinationStorageFolder.CreateFileAsync(destinationFileName, CreationCollisionOption.ReplaceExisting);

        using (var ostream = await file.OpenStreamForWriteAsync())
        {
            int count = 0;
            do
            {
                var buffer = new byte[1024];
                count = streamSource.Read(buffer, 0, 1024);
                await ostream.WriteAsync(buffer, 0, count);
            }
            while (count > 0);
        }

        return destinationStorageFolder.Name + "/" + file.Name;
    }
this is the code I use to read/write. Am I doing something wrong?

Thanks

Viewing all articles
Browse latest Browse all 239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>