Ejemplo n.º 1
0
        public static bool RemoveFile(FileCompareData file)
        {
            try
            {
                if (QuestionDialog($"Are you sure you want to remove {file.name} from {file.path}") == DialogResult.Yes)
                {
                    File.Delete(file.absolutePath);
                    if (Directory.GetFiles(file.path).Length == 0 && Directory.GetDirectories(file.path).Length == 0)
                    {
                        if (QuestionDialog($"Directory {file.path} is Empty. Remove directory?") == DialogResult.Yes)
                        {
                            Directory.Delete(file.path);
                        }
                    }
                }

                return(true);
            }
            catch (Exception exc)
            {
                ErrorDialog($"Error deleting file {file.name}: {exc.Message}");
            }

            return(false);
        }
Ejemplo n.º 2
0
        public FileDataNode(FileCompareData file, int imageIndex)
        {
            this.file          = file;
            ImageIndex         = imageIndex;
            SelectedImageIndex = imageIndex;

            Text             = $"{file.name} ==> {file.absolutePath}";
            ContextMenuStrip = GetMenuStrip();
        }
Ejemplo n.º 3
0
            public override bool Equals(object obj)
            {
                bool retVal = false;

                if (obj is FileCompareData)
                {
                    FileCompareData other = obj as FileCompareData;
                    retVal = Content.SequenceEqual <byte>(other.Content);
                }
                return(retVal);
            }
Ejemplo n.º 4
0
        private void Move(bool isLeft)
        {
            FileCompareData to   = isLeft ? compare.left : compare.right;
            FileCompareData from = isLeft ? compare.right : compare.left;

            var sourceDir   = from.path;
            var destination = $"{from.basePath}{to.localPath}\\{from.name}";

            try
            {
                if (DialogHelper.QuestionDialog($"Are you sure you want to move {from.name} to {destination}") == DialogResult.Yes)
                {
                    if (!Directory.Exists(Path.GetDirectoryName(destination)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(destination));
                    }

                    File.Move(from.absolutePath, destination);
                    if (Directory.GetFiles(sourceDir).Length == 0 && Directory.GetDirectories(sourceDir).Length == 0)
                    {
                        if (DialogHelper.QuestionDialog($"Directory {sourceDir} is Empty. Remove directory?") == DialogResult.Yes)
                        {
                            Directory.Delete(sourceDir);
                        }
                    }

                    // remove node from view
                    if (Parent.Nodes.Count == 1)
                    {
                        Parent.Remove();
                    }
                    else
                    {
                        Remove();
                    }
                }
            }
            catch (Exception exc)
            {
                DialogHelper.ErrorDialog($"Error moving file {from.absolutePath}: {exc.Message}");
            }
        }