📌  相关文章
📜  .net Core 获取文件请求 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:13.094000             🧑  作者: Mango

代码示例2
using System.IO;
var filePath = Path.GetTempFileName();
foreach (var formFile in Request.Form.Files)
{
   if (formFile.Length > 0)
   {
      using (var inputStream = new FileStream(filePath, FileMode.Create))
      {
         // read file to stream
         await formFile.CopyToAsync(inputStream);
         // stream to byte array
         byte[] array = new byte[inputStream.Length];
         inputStream.Seek(0, SeekOrigin.Begin);
         inputStream.Read(array, 0, array.Length);
         // get file name
         string fName = formFile.FileName;
      }
   }
}