private void FollowClick(object sender, RoutedEventArgs e)
        {
            var temp = (TreeDirView.SelectedItem as TreeViewItem);

            if (temp != null)
            {
                var objType = temp.Tag;
                if (objType is FileInfo)
                {
                    var objFile = objType as FileInfo;
                    //для записи в лог
                    var watch = new FileSystemWatcher
                    {
                        Path         = objFile.DirectoryName,
                        NotifyFilter =
                            NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastAccess |
                            NotifyFilters.CreationTime,
                    };
                    watch.Changed            += FileChanged;
                    watch.Created            += FileChanged;
                    watch.Deleted            += FileChanged;
                    watch.Renamed            += FileRenamed;
                    watch.EnableRaisingEvents = true;
                    var folFile = new FollowedFile()
                    {
                        FileOrDirectory = objFile, Path = objFile.FullName
                    };
                    Following.Add(folFile);
                    ListViewFollow.Items.Add(folFile);
                }

                if (objType is DirectoryInfo)
                {
                    var objDir = objType as DirectoryInfo;
                    //для записи в лог
                    var watch = new FileSystemWatcher
                    {
                        Path         = objDir.FullName,
                        NotifyFilter =
                            NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastAccess |
                            NotifyFilters.CreationTime,
                        IncludeSubdirectories = true,
                    };
                    watch.Changed            += FileChanged;
                    watch.Created            += FileChanged;
                    watch.Deleted            += FileChanged;
                    watch.Renamed            += FileRenamed;
                    watch.EnableRaisingEvents = true;

                    var folFile = new FollowedFile()
                    {
                        FileOrDirectory = objDir, Path = objDir.FullName
                    };
                    Following.Add(folFile);
                    ListViewFollow.Items.Add(folFile);
                }
            }
        }
        private void RenameClick(object sender, RoutedEventArgs e)
        {
            var treeItem = (TreeDirView.SelectedItem as TreeViewItem);

            if (treeItem != null)
            {
                var dlg = new RenameFileOfFolder();
                dlg.ShowDialog();
                var newName = RenameFileOfFolder.NewFileName;
                try
                {
                    if (newName != null)
                    {
                        var objectType = treeItem.Tag;
                        if (objectType != null)
                        {
                            if (objectType is FileInfo)
                            {
                                var curPath = objectType as FileInfo;
                                if (curPath.Directory != null)
                                {
                                    var newPath = Path.Combine(curPath.Directory.ToString(), newName);
                                    File.Move(curPath.FullName, newPath + Path.GetExtension(curPath.FullName));
                                    for (var i = 0; i < Following.Count; i++)
                                    {
                                        if (Following[i].FileOrDirectory.ToString() == curPath.Name &&
                                            Following[i].Path.ToString() == curPath.FullName)
                                        {
                                            var renamedFol = new FollowedFile
                                            {
                                                FileOrDirectory = new FileInfo(newName + ".txt"),
                                                Path            = newPath + ".txt"
                                            };
                                            Following[i] = renamedFol;
                                        }
                                    }
                                }
                            }
                            if (objectType is DirectoryInfo)
                            {
                                var    curDir     = objectType as DirectoryInfo;
                                string renamedDir = null;
                                if (curDir.Parent != null)
                                {
                                    renamedDir = curDir.Parent.FullName;
                                    Directory.Move(curDir.FullName, Path.Combine(renamedDir, newName));
                                }
                                for (var i = 0; i < Following.Count; i++)
                                {
                                    if (Following[i].FileOrDirectory.ToString() == curDir.Name && Following[i].Path.ToString() == curDir.FullName)
                                    {
                                        if (renamedDir != null)
                                        {
                                            var renamedFol = new FollowedFile
                                            {
                                                FileOrDirectory = new DirectoryInfo(newName),
                                                Path            = Path.Combine(renamedDir, newName)
                                            };
                                            Following[i] = renamedFol;
                                        }
                                    }
                                }
                            }
                        }
                        RefreshListView();
                        TreeDirView.Items.Refresh();
                    }
                    else
                    {
                        LabelStatus.Content = "Переименование не осуществлено, так как не было задано новое имя...";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }