public ActionResult Import(HttpPostedFileBase currencyConversionsFile)
{
string filename = "CurrencyConversion Upload_" + DateTime.Now.ToString("dd-MM-yyyy") + ".csv";
string folderPath = Server.MapPath("~/Files/");
string filePath = Server.MapPath("~/Files/" + filename);
currencyConversionsFile.SaveAs(filePath);
string[] csvData = System.IO.File.ReadAllLines(filePath);
//the later code isn't show here
}
Run Code Online (Sandbox Code Playgroud)
我知道将httppostedfilebase转换为String数组的常用方法,它首先将文件存储在服务器中,然后从服务器读取数据.无论如何直接从httppostedfilebase获取字符串数组而不将文件存储到服务器中?