Пример #1
0
 private void buttonAllSaveAs_Click(object sender, RoutedEventArgs e)
 {
     if (this.hasReceivedFile())
     {
         System.Array items = this.CopyFileListItems();
         System.Collections.Generic.List <NewFileListItem> temNewFileListItems = new System.Collections.Generic.List <NewFileListItem>();
         foreach (object obj in items)
         {
             NewFileListItem item = obj as NewFileListItem;
             if (item != null)
             {
                 temNewFileListItems.Add(item);
             }
         }
         FolderBrowserDialog fdb = new FolderBrowserDialog();
         fdb.SelectedPath = this.sessionService.SaveAsFilePath;
         DialogResult dr = fdb.ShowDialog();
         if (DialogResult.OK == dr && fdb.SelectedPath != string.Empty)
         {
             this.MakeSameNameFile(temNewFileListItems);
             int existedFileCount    = this.GetExistedFileCount(fdb.SelectedPath + "\\", temNewFileListItems);
             MessageBoxResult result = MessageBoxResult.None;
             if (existedFileCount != 0)
             {
                 result = System.Windows.MessageBox.Show(string.Format("接收文件目录:{0},一共存在({1})个同名文件.是:全部覆盖,否:自动命名", fdb.SelectedPath + "\\", existedFileCount), "友情提示", MessageBoxButton.YesNoCancel);
                 if (result == MessageBoxResult.Cancel)
                 {
                     return;
                 }
             }
             this.MakeSameNameFile(temNewFileListItems);
             System.Collections.Generic.List <string> processingFileNames = new System.Collections.Generic.List <string>();
             foreach (object obj in temNewFileListItems)
             {
                 NewFileListItem item = obj as NewFileListItem;
                 if (item != null)
                 {
                     item.SaveAs(fdb.SelectedPath + "\\", this.GetExistedFileCount(fdb.SelectedPath + "\\", temNewFileListItems), processingFileNames, result);
                 }
             }
             this.sessionService.SaveAsFilePath = fdb.SelectedPath + "\\";
         }
     }
 }
Пример #2
0
 private void buttonAllAccept_Click(object sender, RoutedEventArgs e)
 {
     if (this.hasReceivedFile())
     {
         System.Array items = this.CopyFileListItems();
         System.Collections.Generic.List <NewFileListItem> temNewFileListItems = new System.Collections.Generic.List <NewFileListItem>();
         foreach (object obj in items)
         {
             NewFileListItem item = obj as NewFileListItem;
             if (item != null)
             {
                 temNewFileListItems.Add(item);
             }
         }
         this.MakeSameNameFile(temNewFileListItems);
         int existedFileCount    = this.GetExistedFileCount(this.fileDir, temNewFileListItems);
         MessageBoxResult result = MessageBoxResult.None;
         if (existedFileCount != 0)
         {
             result = System.Windows.MessageBox.Show(string.Format("接收文件目录:{0},一共存在({1})个同名文件.是:全部覆盖,否:自动命名", this.fileDir, existedFileCount), "友情提示", MessageBoxButton.YesNoCancel);
             if (result == MessageBoxResult.Cancel)
             {
                 return;
             }
         }
         this.MakeSameNameFile(temNewFileListItems);
         System.Collections.Generic.List <string> processingFileNames = new System.Collections.Generic.List <string>();
         foreach (object obj in temNewFileListItems)
         {
             NewFileListItem item = obj as NewFileListItem;
             if (item != null)
             {
                 item.SaveAs(this.fileDir, this.GetExistedFileCount(this.fileDir, temNewFileListItems), processingFileNames, result);
             }
         }
     }
 }