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)
Thanks
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