Skip to content

Commit 74940fe

Browse files
authored
Update MemoryWebClient.cs
1 parent 29d5ad3 commit 74940fe

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

clients/dotnet/WebClient/MemoryWebClient.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All rights reserved.
1+
// Copyright (c) Microsoft. All rights reserved.
22

33
using System;
44
using System.Collections.Generic;
@@ -438,18 +438,16 @@ private async Task<string> ImportInternalAsync(
438438
// Add files to the form
439439
for (int i = 0; i < uploadRequest.Files.Count; i++)
440440
{
441-
using Stream fileStream = uploadRequest.Files[i].FileContent;
442-
443-
if (fileStream.CanSeek && fileStream.Position > 0)
441+
if (uploadRequest.Files[i].FileContent is { CanSeek: true, Position: > 0 })
444442
{
445-
fileStream.Seek(0, SeekOrigin.Begin);
443+
uploadRequest.Files[i].FileContent.Seek(0, SeekOrigin.Begin);
446444
}
447445

448446
string fileName = uploadRequest.Files[i].FileName;
449447
byte[] bytes;
450-
using (var binaryReader = new BinaryReader(fileStream))
448+
using (var binaryReader = new BinaryReader(uploadRequest.Files[i].FileContent))
451449
{
452-
bytes = binaryReader.ReadBytes((int)fileStream.Length);
450+
bytes = binaryReader.ReadBytes((int)uploadRequest.Files[i].FileContent.Length);
453451
}
454452

455453
var fileContent = new ByteArrayContent(bytes, 0, bytes.Length);

0 commit comments

Comments
 (0)