// Collection of code snippets by Arne Vajhøj // posted to eksperten.dk, usenet and other places (2002-now) using System; using System.IO; using System.Drawing; using System.Windows.Forms; public class MainForm : Form { private Label status; private Button start; private Button abort; private Timer t; public MainForm() { status = new Label(); start = new Button(); abort = new Button(); SuspendLayout(); status.Location = new Point(50, 50); status.Size = new Size(200, 50); status.Name = "Status TextBox"; status.Font = new Font(FontFamily.GenericSerif, 24); status.Text = "Stopped"; status.ForeColor = Color.Red; start.Location = new Point(50, 150); start.Size = new Size(200, 50); start.Name = "Start Button"; start.Text = "Start"; start.Click += new EventHandler(StartClick); abort.Location = new Point(50, 250); abort.Size = new Size(200, 50); abort.Name = "Abort Button"; abort.Text = "Abort"; abort.Click += new EventHandler(AbortClick); ClientSize = new Size(300, 350); Controls.Add(status); Controls.Add(start); Controls.Add(abort); Name = "Main Form"; Text = "Main Form"; ResumeLayout(false); t = new Timer(); t.Interval = 60 * 1000; t.Tick += new EventHandler(DoIt); } private void XCopy(string dir1, string dir2) { string[] files = Directory.GetFiles(dir1); foreach (string f in files) { File.Copy(f, dir2 + f.Substring(dir1.Length), true); } string[] dirs = Directory.GetDirectories(dir1); foreach (string d in dirs) { XCopy(d, dir2 + d.Substring(dir1.Length)); } } private void DoIt(object sender, EventArgs e) { XCopy("C:\\fra", "C:\\til"); } private void StartClick(object sender, EventArgs e) { t.Start(); status.Text = "Started"; status.ForeColor = Color.Green; } private void AbortClick(object sender, EventArgs e) { t.Stop(); status.Text = "Stopped"; status.ForeColor = Color.Red; } [STAThread()] public static void Main(string[] args) { Application.Run(new MainForm()); Application.Exit(); Environment.Exit(0); } }