Hi everyone,
i'm exporting datagridview to txt file.
first 2 lines of txt are defined in advanced.
other lines of txt should be exported from datagridview.
I manage to do it, but for each line which will be written in txt i need to add 0x0D carriage return and 0x0A line feed.
Can you help me how to add carriage and line feed.
My code is bellow.
Thank you.
- tw.WriteLine(cban + cname + ccity + date + blanko + mbank + nula).ToString();// on the end of this line i have to add carriage return(0x0D), and Line feed (0x0A)
- tw.WriteLine(cban + cname + ccity + totamount.ToString() + totalxml.ToString() + blanko2 + type);// on the end of this line i have to add carriage return(0x0D), and Line feed (0x0A)
- for (int i = 0; i <= dataGridView1.Rows.Count - 1; i++)
- {
- for (int j = 0; j <= dataGridView1.Columns.Count - 1; j++)
- {
- sLine = sLine + dataGridView1.Rows[i].Cells[j].Value;
- }
- tw.WriteLine(sLine); //also for each line written from datagridview i have to add on the end of each line carriage return(0x0D), and Line feed (0x0A)
- sLine = "";
- }

Sachin SinghRank #66 · 26.2K reputationPosted Nov 6, 2020, 3:33 AM EST
Encoding ascii = Encoding.ASCII;Mario ScheerenRank #1,371 · 1.2K reputationPosted Nov 3, 2020, 6:06 AM EST
Ben ThompsonRank #8,839 · 215 reputationPosted Nov 5, 2020, 10:34 AM EST
Mario ScheerenRank #1,371 · 1.2K reputationPosted Nov 6, 2020, 3:16 AM EST
Ashutosh GuptaRank #805 · 2.9K reputationPosted Nov 7, 2020, 2:19 AM EST
Sachin SinghRank #66 · 26.2K reputationPosted Nov 5, 2020, 5:12 PM EST
Vuk Stanojevic163 reputationPosted Nov 6, 2020, 2:55 AM EST