Ejemplo n.º 1
0
        public void listViewItemClicked()
        {
            DirectoryElement directoryElement = view.GetListBoxItem;

            if (directoryElement.Type == DirectoryElementType.DIRECTORY && directoryElement != null)
            {
                view.CurrentPath = directoryElement.Name;
                view.ClearListBoxItems();
                view.DirectoryElements = model.LoadPathFiles(view.CurrentPath);
            }
        }
Ejemplo n.º 2
0
        public void Delete(DirectoryElement name)
        {
            if (name != null)
            {
                string path = name.Name;

                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                else
                {
                    Directory.Delete(path);
                }
            }
        }
Ejemplo n.º 3
0
        internal void Move(DirectoryElement source, string msg)
        {
            int    index    = source.Name.LastIndexOf("\\");
            string leftName = source.Name.Substring(index);

            try
            {
                if (source.Type == DirectoryElementType.FILE)
                {
                    File.Move(source.Name, msg);
                }
                else
                {
                    Directory.Move(source.Name, msg);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Ejemplo n.º 4
0
        public void Copy(DirectoryElement left, string right)
        {
            //TODO: case file exist exeption handling
            if (left.Type == DirectoryElementType.FILE)
            {
                File.Copy(left.Name, $"{right}\\{Path.GetFileName(left.Name)}");
            }
            else
            {
                foreach (string dirPath in Directory.GetDirectories(left.Name, "*", SearchOption.AllDirectories))
                {
                    Directory.CreateDirectory(dirPath.Replace(left.Name, right));
                }

                //Copy all the files & Replaces any files with the same name
                foreach (string newPath in Directory.GetFiles(left.Name, "*.*", SearchOption.AllDirectories))
                {
                    File.Copy(newPath, newPath.Replace(left.Name, right), true);
                }
            }
        }
Ejemplo n.º 5
0
        public void Move(DirectoryElement left, DirectoryElement right)
        {
            int    index    = left.Name.LastIndexOf("\\");
            string leftName = left.Name.Substring(index);

            try
            {
                if (left.Type == DirectoryElementType.FILE)
                {
                    File.Move(left.Name, right.Name + leftName);
                }
                else
                {
                    if (right.Type == DirectoryElementType.DIRECTORY)
                    {
                        Directory.Move(left.Name, right.Name);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }