我是一名学生,正在尝试另一个迷你项目,用户可以将 CSV 文件上传到 Web 服务器。但在我创建另一个程序来执行文件之前,我想将文件发送到 virustotal 以检查病毒。
我试过了,但出现错误:“无法从 'string' 转换为 'System.IO.FileInfo'”
这是我的代码:
控制器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VirusTotalNET;
namespace Testing_1.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
public ActionResult Upload(HttpPostedFileBase file)
{
string filename = file.FileName;
VirusTotal vtObj = new VirusTotal("%API KEY%");
string resID = vtObj.ScanFile(file.FileName);
string path = Server.MapPath("~/CSV/" + file.FileName);
file.SaveAs(path);
ViewBag.Path = path;
return View();
}
}
}
我在这一行得到了错误:string resID = vtObj.ScanFile(file.FileName);
指数
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="File" id="file"/>
<input type="submit" value="Upload" />
}
上传
@{
ViewBag.Title = "Upload";
}
<h2>Uploaded: @ViewBag.Path</h2>
请帮帮我谢谢