Skip to content

Instantly share code, notes, and snippets.

@scattered-code
Last active September 21, 2020 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scattered-code/aa85aec790de8f75df25c7e25588fb2b to your computer and use it in GitHub Desktop.
Save scattered-code/aa85aec790de8f75df25c7e25588fb2b to your computer and use it in GitHub Desktop.
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