I can parse a CSV file by using the file path and TextFieldParser. Now I'm trying to parse a CSV file received from InputFile component. Here is what I tried:
var stream = e.File.OpenReadStream();
var memoryStream = new MemoryStream();
await stream.CopyToAsync(memoryStream);
stream.Close();
using (var parser = new TextFieldParser(memoryStream))
{
parser.TextFieldType = FieldType.Delimited;
parser.SetDelimiters(";", ",");
while (!parser.EndOfData)
{
//Do something here
}
}
But when I run that, it does not enter the using block and never go further. What should I do?
Thanks
use try-catch block for see Exceptions and error details.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.