Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var tempFilename = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.tmp");
using (var stream = new FileStream(tempFilename, FileMode.CreateNew))
{
const int chunkSize = 1024;
var buffer = new byte[chunkSize];
var bytesRead = 0;
do
{
bytesRead = await fileSection.FileStream.ReadAsync(buffer, 0, buffer.Length);
await stream.WriteAsync(buffer, 0, bytesRead);
} while (bytesRead > 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment