c# - How can i find out the Last row in a datagridview and write it to text file -


i find last row of datagridview , write particular row data text file can 1 me

i give sample code, may help.

 list<string> lstcontents = new list<string>();         foreach (datagridviewcell cell in mydatagrid.rows[mydatagrid.rowcount - 1].cells)         {             lstcontents .add((string)cell.value);         }  string mydata= string.join(",", lstcontents.toarray()); 

now using streamwriter can write string file. can use separator. have used "," comma here. ///this append data text file...

using (streamwriter sw = new streamwriter(filepath, true))         {             sw.writeline(mydata);         } 

Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -