CSL_Test__1.TorrentXMLHandler.Initialize C# (CSharp) Method

Initialize() public static method

public static Initialize ( ) : void
return void
        public static void Initialize()
        {
            DataColumn column;

            if (File.Exists(xmlSchemaName))
            {
                dataset = new DataSet();
                xmlStream = new FileStream(xmlSchemaName, FileMode.Open);
                dataset.ReadXmlSchema(xmlStream);
                table = dataset.Tables[0];
                xmlStream.Close();
            }
            else
            {
                dataset = new DataSet("TorrentSet");
                table = new DataTable("Torrent");

                table.Columns.Add("Site Origin", typeof(string));
                table.Columns.Add("Artist", typeof(string));
                table.Columns.Add("Album", typeof(string));
                table.Columns.Add("Save Structure", typeof(string));
                table.Columns.Add("Year", typeof(string));
                table.Columns.Add("Bitrate", typeof(string));
                table.Columns.Add("Release Format", typeof(string));
                table.Columns.Add("Physical Format", typeof(string));
                table.Columns.Add("Bit Format", typeof(string));

                //Handle Column
                column = new DataColumn();
                column.ReadOnly = true;
                column.DataType = typeof(bool);
                column.ColumnName = "Handled";
                table.Columns.Add(column);
                //Error Column
                column = new DataColumn();
                column.ReadOnly = true;
                column.DataType = typeof(bool);
                column.ColumnName = "Error";
                table.Columns.Add(column);

                table.Columns.Add("File", typeof(string));
                table.Columns.Add("File Path", typeof(string));
                dataset.Tables.Add(table);
                table.PrimaryKey = new DataColumn[] { table.Columns["File"] };

                xmlStream = new FileStream(xmlSchemaName, FileMode.CreateNew);
                dataset.WriteXmlSchema(xmlStream);
                xmlStream.Close();
            }

            if (File.Exists(xmlDataPath))
            {
                xmlStream = new FileStream(xmlDataPath, FileMode.Open);
                try
                {
                    table.ReadXml(xmlStream);
                }
                catch
                {
                    xmlStream.Close();
                    xmlStream = new FileStream(xmlDataPath, FileMode.Create);
                    xmlStream.Close();
                }
            }
        }