iformfile to stream c# code example
Example 1: C# convert iformfile to stream
foreach (var file in files)
{
if (file.Length > 0)
{
using (var ms = new MemoryStream())
{
file.CopyTo(ms);
var fileBytes = ms.ToArray();
string s = Convert.ToBase64String(fileBytes);
// act on the Base64 data
}
}
}
Example 2: c# write iformfile
(in async function)
using (Stream fileStream = new FileStream(filePath, FileMode.Create)) {
await file.CopyToAsync(fileStream);
}