<pre lang="c#"> //Form1.cs using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Threading; using Microsoft.Win32; namespace AutoBackup { public partial class Form1 : Form { Backup objBackup = new Backup(); NotifyIcon notifyIcon = new NotifyIcon(); RegistryKey reg = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce", true); public Form1() { InitializeComponent(); Thread splashthread = new Thread(new ThreadStart(objBackup.backup)); splashthread.IsBackground = true; try { //objBackup.IPAddress(); System.Timers.Timer BackUpTimer = new System.Timers.Timer(); BackUpTimer.Interval = Convert.ToInt32(2000); //replicationTimer.Interval = 300000; BackUpTimer.Elapsed += new System.Timers.ElapsedEventHandler(MyTimer_Elapsed); BackUpTimer.Start(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void MyTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { } } } //Backup.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Xml; namespace AutoBackup { public class Backup { string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); public void backup() { using (XmlWriter writer = XmlWriter.Create(path+"\\BackupDetails.xml")) { writer.WriteStartElement("Backups"); writer.WriteElementString("Time", DateTime.Now.ToString()); writer.WriteEndElement(); writer.Flush(); } } } }
BackUpTimer.Interval = Convert.ToInt32(2000);
BackUpTimer.Interval = Convert.ToInt32(2000 * 60);
Interval
Convert.ToInt32(2000 * 60)
MyTimer_Elapsed
Backup myBackup = new Backup(); myBackup.backup();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)