.Net core API 读取文件并拷贝到指定目录
public IActionResult UploadReportLogo([FromForm,Required] IFormFile file) { if (file == null || file.Length == 0) return BadRequest("Can not find file"); string logoPath = Path.Combine(Directory.GetCurrentDirectory(), Settings.STATIC_FOLDER_LOGO).ToString(); Stream stream = file.OpenReadStream(); //byte[] bytes = new byte[stream.Length]; //stream.Read(bytes, 0, bytes.Length); string fileName = file.FileName; Stream writeTo = System.IO.File.Create(logoPath+ fileName); stream.CopyTo(writeTo); writeTo.Dispose(); return Ok("Success"); }