private bool CarregarArquivo(string cArquivo)
{
if (File.Exists(cArquivo))
{
TextReader txt = new StreamReader(cArquivo, Encoding.Default, true);
try
{
int nNota = -1;
string cLinhaTXT = txt.ReadLine();
if (cLinhaTXT != null)
{
if (!cLinhaTXT.StartsWith("NOTAFISCAL") && !cLinhaTXT.StartsWith("NOTA FISCAL"))
{
this.cMensagemErro = " Conteúdo da primeira linha do arquivo deve ser 'NOTAFISCAL'";
}
cLinhaTXT = txt.ReadLine();
this.LinhaLida = 1;
}
while (cLinhaTXT != null)
{
++LinhaLida;
if (cLinhaTXT.Trim().Length > 0)
{
if (cLinhaTXT.StartsWith("A|"))
{
++nNota;
xConteudoArquivo.Add(nNota, new List<string>());
}
List<string> temp;
xConteudoArquivo.TryGetValue(nNota, out temp);
temp.Add(prefix + cLinhaTXT.Trim() + (!cLinhaTXT.EndsWith("|") ? "|" : ""));
}
cLinhaTXT = txt.ReadLine();
}
}
catch (IOException ex)
{
this.cMensagemErro += ex.Message;
}
catch (Exception ex)
{
this.cMensagemErro += ex.Message;
}
finally
{
txt.Close();
}
}
else
this.cMensagemErro = "Arquivo [" + cArquivo + "] não encontrado";
return ((this.xConteudoArquivo.Count == 0 || !string.IsNullOrEmpty(this.cMensagemErro)) ? false : true);
}