I get a .csv file in my Controller . This file can contain two templates , with 2 or 5 lines.
First I have to do the validation to check if the file contains 5 lines:
var arquivo = new StreamReader(model.Arquivo.InputStream, Encoding.UTF7);
var arquivoValida = new StreamReader(model.Arquivo.InputStream, Encoding.UTF7);
if (this.TipoArquivoLCCP(arquivoValida, out listaRetorno, out numColunasLCCP, out isLCCP)) { }
private bool TipoArquivoLCCP(StreamReader arquivoLCCP, out object listaRetorno, out int numColunasLCCP, out bool isLCCP)
{
while (arquivoLCCP.Peek() > -1)
{ /* Verificação */ }
If this check returns false
, I go to the second method that does the other check:
if (!isLCCP && this.ValidarArquivo(arquivo, model.TipoPagina, model.Pais, out listaRetorno, out numColunas))
{ ... }
Method ValidarArquivo()
:
private bool ValidarArquivo(StreamReader arquivo, Enumeradores.TipoPaginaUploadColeta tipoPagina, string idPais, out object listaRetorno, out int numColunas)
{
while (arquivo.Peek() > -1)
{ ... }
The problem is that the command
while (arquivo.Peek() > -1) { ... }
It always returns -1 and I can not get into the validations.
As you can see, I created two different variables that get my file:
var arquivo = new StreamReader(model.Arquivo.InputStream, Encoding.UTF7);
var arquivoValida = new StreamReader(model.Arquivo.InputStream, Encoding.UTF7);
I use each of them in a method, but it still does not work.