0
I developed the code below to put information of a return from a bank select in a CSV file, however as you can see in attached print, some characters are being sent wrong even if the return from select is correct, in which way I could put a UTF-8 or other charset. One interesting thing that also did not understand what happened is that big numbers are coming wrong in the display but when I click on them appears the number correctly.
p.s the commented part was something I tried to use but did not succeed.
List<RemessaArquivo> Dados = bll.Dados(ID);
System.Text.StringBuilder ConteudoArq = new System.Text.StringBuilder();
System.Text.StringBuilder ConteudoLin = new System.Text.StringBuilder();
//Matriz para criar todas as linhas e colunas com os dados
Dados.ForEach(x =>
{
// uso do reflection nas linhas
Type type = typeof(RemessaArquivo);
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo property in properties)
{
ConteudoLinha.Append(property.GetValue(x, null) + ";");
}
ConteudoArquivo.AppendLine(ConteudoLin.ToString());
ConteudoLinha.Clear();
});
/* string auxConversao = "";
byte[] bytes = Encoding.Default.GetBytes(ConteudoArquivo.ToString());
auxConversao = Encoding.UTF8.GetString(bytes);
*/
//Definindo onde o arquivo será gerado
using (System.IO.StreamWriter arquivoCSV = new StreamWriter(@"C:\ArquivosRemessa\arquivo.csv", false))
{
arquivoCSV.WriteLine(ConteudoArq.ToString());
arquivoCSV.Close();
}
I have tried yes, I have the following error return:
– Matheus Muniz
Error 57 Argument 2: cannot Convert from 'System.Text.Encoding' to 'bool'
– Matheus Muniz
Based on what you told me, I thought to send the false between the 2 parameters, I edited your question, thank you very much, the data are coming correctly!
– Matheus Muniz