Ejemplo n.º 1
0
        /// <summary>
        /// Read the configuration
        /// </summary>
        /// <returns></returns>
        public static SyncConfig ReadConfig()
        {
            SyncConfig retValue = null;
            string     path     = FullPath;

            if (!File.Exists(path))
            {
                retValue             = new SyncConfig();
                retValue.IgnoreFiles = new List <string>()
                {
                    "Thumbs.db"
                };
                WriteConfig(retValue);
            }
            else
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(SyncConfig));
                using (StreamReader textReader = new StreamReader(path))
                    retValue = xmlSerializer.Deserialize(textReader) as SyncConfig;
            }
            return(retValue);
        }
Ejemplo n.º 2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtSrcFolder.Text) &&
                !string.IsNullOrEmpty(txtDstFolder.Text))
            {
                if (!Directory.Exists(txtSrcFolder.Text))
                {
                    MessageBox.Show("SOURCE FOLDER DOES NOT EXIST!");
                }
                else if (!Directory.Exists(txtDstFolder.Text))
                {
                    MessageBox.Show("DESTINATION FOLDER DOES NOT EXIST!");
                }
                else
                {
                    btnCancel.Visible  = true;
                    btnStart.Enabled   = false;
                    grpFolders.Enabled = false;

                    txtTraces.Text = "";

                    syncConfig.SourceFolder      = txtSrcFolder.Text;
                    syncConfig.DestinationFolder = txtDstFolder.Text;
                    SyncConfig.WriteConfig(syncConfig);

                    syncFolders             = new SyncFolders(txtSrcFolder.Text, txtDstFolder.Text, syncConfig.TraceLevel, syncConfig.IgnoreFiles);
                    syncFolders.TraceFired += SyncFolders_TraceFired;
                    syncFolders.Finished   += SyncFolders_Finished;
                    syncFolders.StartSyncFolders();
                }
            }
            else
            {
                MessageBox.Show("YOU HAVE TO FILL SOURCE AND DESTINATION FOLDER!");
            }
        }