AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="0.9.11" />

 FileDataSetEntry

A file entry in a form.
using AngleSharp.Dom.Io; using AngleSharp.Network; using System.IO; using System.Text; namespace AngleSharp.Html { internal sealed class FileDataSetEntry : FormDataSetEntry { private readonly IFile _value; public string FileName => _value?.Name ?? string.Empty; public string ContentType => _value?.Type ?? MimeTypeNames.Binary; public FileDataSetEntry(string name, IFile value, string type) : base(name, type) { _value = value; } public override bool Contains(string boundary, Encoding encoding) { bool result = false; Stream stream = _value?.Body; if (stream != null && stream.CanSeek) { using (StreamReader streamReader = new StreamReader(stream, encoding, false, 4096, true)) { while (streamReader.Peek() != -1) { if (streamReader.ReadLine().Contains(boundary)) { result = true; break; } } } stream.Seek(0, SeekOrigin.Begin); } return result; } public override void Accept(IFormDataSetVisitor visitor) { visitor.File(this, FileName, ContentType, _value); } } }