SoFunction
Updated on 2025-03-07

Simple example of exporting logs to txt text in C#


/// <summary>
/// Log
        /// </summary>
        /// <param name="log"></param>

//First of all, you have to use;
        public void Write(ArrayList log)
            {
//Save the file on the desktop, the file name is the current time.txt
                FileStream fs = new
                                  FileStream("C:\\Users\\ailin\\Desktop\\" +
                                  ().Replace(":", "") + ".txt", , );
                    StreamWriter sw = new StreamWriter(fs, );
                    foreach( string i in log)
                    {

                            (());

                    }
                     DateTime dt1 = ;
                     ();
("Operator: cxx");
("Date:"+(dt1));
                     ();
                     ();
            }

            //string sSaveExcelName =
        //"C:\\" + ().Replace("-", "") + ().Replace(":", "") + ".xls";
         public static ArrayList aChg_Slab_Len = new ArrayList();
            private void button2_Click(object sender, EventArgs e)
            {


                    ArrayList cx = new ArrayList();

                    for (int i = 0; i < ; i++)
                    {
                        for (int j = 0; j < ; j++)
                        {
                           ([i, j].Text);
                           ("  ");
                        }
                        ("\r\n");

                    }
//Perform the operation of exporting the log
                    Write(cx);
                    return;

            }