示例#1
0
        private static void OnDialogResultChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RenameFileDialog dialog = d as RenameFileDialog;

            if (dialog.DialogResultChanged != null)
            {
                dialog.DialogResultChanged.Invoke(dialog, null);
            }
        }
        private void OnRename(object parameter)
        {
            bool NameAlreadyExist = false;

            while (true)
            {
                if (fileList.SelectedItems.Count == 1)
                {
                    FileItem         item   = fileList.SelectedItems[0] as FileItem;
                    RenameFileDialog rename = new RenameFileDialog();
                    if (NameAlreadyExist)
                    {
                        rename.FileExist = Visibility.Visible;
                    }
                    else
                    {
                        rename.FileExist = Visibility.Collapsed;
                    }
                    rename.NewFileName = item.Name;
                    rename.ShowDialog();
                    DialogResult result = rename.DialogResult;
                    if (string.IsNullOrEmpty(rename.NewFileName) || rename.NewFileName == item.Name)
                    {
                        return;
                    }
                    switch (result)
                    {
                    case DialogResult.No:
                        return;

                    case DialogResult.Cancel:
                        return;
                    }

                    if (!string.IsNullOrEmpty(SubFolder))
                    {
                        string pathString = System.IO.Path.Combine(installedLocation, SubFolder.ToString());
                        string old        = pathString + "/" + item;
                        string newfile    = pathString + "/" + rename.NewFileName;
                        //if (File.Exists(pathString + "/" + item))
                        //{
                        File.Copy(old, newfile);
                        //}
                    }


                    item.Name = rename.NewFileName;
                    return;
                }
            }
        }