I work on c# 7 I face issue I can't get data from file Request.form.file[0] directly
it must copying to server to get data from it
so can i get data from variable DisplayFileName
instead of get data from input path after copying to server
below is my code :
//step1 get file from angular
var DisplayFileName = Request.Form.Files[0];
//step2 modify file name to be unique to avoid make error if exist before
string fileName = DisplayFileName.FileName.Replace(".xlsx", "-") + DateTime.Now.Ticks.ToString() + ".xlsx";
// step3 make unique input path with input data but not create yet
string inputpath = Path.Combine(myValue1, DateTime.Now.Month.ToString(), fileName);
// step4 make unique output path will export final result to it but not create yet
string exportPath = Path.Combine(myValue2, DateTime.Now.Month.ToString(), fileName);
CExcel ex = new CExcel();
//step5 check input file have data
if (fileName.Length > 0)
{
//step6 create file with input data i uploaded on server path on Input folder
using (var stream = new FileStream(inputpath, FileMode.Create))
{
Request.Form.Files[0].CopyTo(stream);
}
with another meaning How to get data direct from
DisplayFileName
I don't need get data from inputpath variable
that i create on server
for more details how to get data direct from step1
instead of get data from step 6 after copying data to server ?
How to get data direct from step 1 please ?