// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using MySql.Data.MySqlClient; class MainClass { public static void Main(string[] args) { MySqlConnection con = new MySqlConnection("Database=Test;Data Source=localhost;User Id=;Password="); con.Open(); MySqlCommand cre = new MySqlCommand("CREATE TABLE files (filename INTEGER PRIMARY KEY AUTO_INCREMENT, content TEXT)", con); cre.ExecuteNonQuery(); MySqlCommand ins = new MySqlCommand("INSERT INTO files(content) VALUES (?content)", con); ins.Parameters.Add("?content", MySqlDbType.Blob); string[] filenames = Directory.GetFiles(@"C:\scripts", "*.bat"); for(int i = 0; i < filenames.Length; i++) { StreamReader sr = new StreamReader(filenames[i]); string content = sr.ReadToEnd(); sr.Close(); ins.Parameters["?content"].Value = content; ins.ExecuteNonQuery(); } MySqlCommand drp = new MySqlCommand("DROP TABLE files", con); drp.ExecuteNonQuery(); con.Close(); } }