Пример #1
0
        private void OnDeleted(object source, FileSystemEventArgs e)
        {
            FlatCopyApplicationContext.SetWorkIcon();
            Console.WriteLine($"file deleted {e.FullPath}");
            var counterPart = GetCounterFullPath(e.FullPath);

            Console.WriteLine($"del->        {counterPart}");
            if (!IsDirectory(e.FullPath))
            {
                try
                {
                    File.Delete(counterPart);
                }
                catch (Exception) { }
            }
            else
            {
                var    files = Directory.EnumerateFiles(e.FullPath, "*.*", SearchOption.AllDirectories);
                string pathPart;
                foreach (var file in files)
                {
                    var tmp = file.Replace(e.FullPath, "");
                    pathPart = e.FullPath + tmp;
                    pathPart = pathPart.Replace(sourceDir, "");
                    pathPart = pathPart.Replace(@"\", ".");
                    var oldCounterFile = destinationDir + pathPart;

                    File.Delete(oldCounterFile);
                }
            }
            FlatCopyApplicationContext.UnsetWorkicon();
        }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     FlatCopyApplicationContext.sourceFolder = this.textBox1.Text;
     FlatCopyApplicationContext.destFolder   = this.textBox2.Text;
     FlatCopyApplicationContext.filter       = this.textBoxFilter.Text;
     FlatCopyApplicationContext.SaveSettings();
     this.Close();
 }
Пример #3
0
        //copy all now
        private void button2_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == MessageBox.Show(
                    this,
                    "This will DELETE ALL files in the Target Folder, and copy the files from the source folder into the target folder (flattened)", "Delete all files in Target Folder?",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Warning))
            {
                FlatCopyApplicationContext.sourceFolder = this.textBox1.Text;
                FlatCopyApplicationContext.destFolder   = this.textBox2.Text;
                FlatCopyApplicationContext.filter       = this.textBoxFilter.Text;

                FlatCopyApplicationContext.ResyncAllNow();
            }
        }
Пример #4
0
        private void OnCreated(object source, FileSystemEventArgs e)
        {
            FlatCopyApplicationContext.SetWorkIcon();
            Console.WriteLine($"file created {e.FullPath}");
            var counterPart = GetCounterFullPath(e.FullPath);

            Console.WriteLine($"overwrite->  {counterPart}");
            if (!IsDirectory(e.FullPath))
            {
                try
                {
                    File.Copy(e.FullPath, counterPart);
                }
                catch (Exception) { }
            }
            FlatCopyApplicationContext.UnsetWorkicon();
        }
Пример #5
0
        private void OnRenamed(object source, RenamedEventArgs e)
        {
            FlatCopyApplicationContext.SetWorkIcon();

            Console.WriteLine($"file renamed {e.OldFullPath} to {e.FullPath} ");
            var oldCounterPart = GetCounterFullPath(e.OldFullPath);
            var newCounterPart = GetCounterFullPath(e.FullPath);

            Console.WriteLine($"rename->  {oldCounterPart} to {newCounterPart}");
            try
            {
                if (!IsDirectory(e.FullPath))
                {
                    File.Move(oldCounterPart, newCounterPart);
                }
                else
                {
                    var    files = Directory.EnumerateFiles(e.FullPath, "*.*", SearchOption.AllDirectories);
                    string pathPart;
                    foreach (var file in files)
                    {
                        var tmp = file.Replace(e.FullPath, "");
                        pathPart = e.OldFullPath + tmp;
                        pathPart = pathPart.Replace(sourceDir, "");
                        pathPart = pathPart.Replace(@"\", ".");
                        var oldCounterFile = destinationDir + pathPart;


                        pathPart = file.Replace(sourceDir, "");
                        pathPart = pathPart.Replace(@"\", ".");
                        var newCounterFile = destinationDir + pathPart;

                        File.Move(oldCounterFile, newCounterFile);
                    }
                }
            }
            catch (Exception) { }
            FlatCopyApplicationContext.UnsetWorkicon();
        }