Esempio n. 1
0
        public static void SaveDB(DataTable dt)
        {
            string       text1   = Environment.CurrentDirectory + @"\Data\" + dt.TableName + ".csv";
            StreamWriter writer1 = File.CreateText(text1);

            try
            {
                StringBuilder builder1 = new StringBuilder();
                for (int num1 = 0; num1 < dt.Columns.Count; num1++)
                {
                    if (num1 != 0)
                    {
                        builder1.Append(',');
                    }
                    builder1.Append(dt.Columns[num1].ColumnName);
                }
                builder1.Append("\r\n");
                foreach (DataRow row1 in dt.Rows)
                {
                    for (int num2 = 0; num2 < dt.Columns.Count; num2++)
                    {
                        if (num2 != 0)
                        {
                            builder1.Append(',');
                        }
                        builder1.Append(StockDB.EncodeCSV(row1[num2].ToString()));
                    }
                    builder1.Append("\r\n");
                }
                writer1.Write(builder1.ToString());
            }
            finally
            {
                writer1.Close();
            }
        }