private void m_AppFrame_OnTimer_Sub1(object sender, RscAppFrameTimerEventArgs e) { switch (e.Reason) { case "copy move files_Cancel": { m_AppFrame.SetStatusText("User canceled operation!", StatusColoring.Error); break; } case "copy move files": { int iRootLen = m_txtRootFldr.Text.Length; if (e.Pos == 0) { foreach (RscFileItemDesc itFldr in m_folders) { string sPart = itFldr.Path.Substring(iRootLen); if (sPart.Length > 0) { string sNewFolder = m_sCopyMoveDest; if (iRootLen == 0) { sNewFolder += "\\"; } sNewFolder += sPart; try { RscStore store = new RscStore(); store.CreateFolder(sNewFolder); } catch (Exception /*exc*/) { m_AppFrame.SetStatusText("ERR: Unable to copy folder stru near: " + sNewFolder, StatusColoring.Error); e.Completed = true; return; } } } e.Max = 1; } else { RscFileItemDesc it = m_files[e.Pos - 1]; string sErr = ""; try { string sCopyMoveTo = m_sCopyMoveDest; if (iRootLen == 0) { sCopyMoveTo += "\\"; } sCopyMoveTo += it.Path.Substring(iRootLen); RscStore store = new RscStore(); if (m_sCopyMove == "move") { store.MoveFileForce(it.Path, sCopyMoveTo); } else { store.CopyFileForce(it.Path, sCopyMoveTo); } } catch (Exception exc) { sErr = "Unable to " + m_sCopyMove + " file.\r\n" + exc.Message; } if (sErr.Length == 0) { m_files.RemoveAt(e.Pos - 1); if ((e.Pos - 1) < m_files.Count) { int iPos = e.Pos; e.Pos = iPos; //Denie subsys to increment... } else { e.Completed = true; } } else { it.LastError = sErr; //ReQuery... lbFiles.ItemsSource = null; lbFiles.ItemsSource = m_files; if ((e.Pos - 1) < (m_files.Count - 1)) { e.Max++; } else { e.Completed = true; } } if (e.Completed) { if (m_sCopyMove == "move") { if (m_files.Count == 0) //Otherwise error occured... { if (chbRecurse.IsChecked.Value) //Otherwise no sub-tree deletion... { int iIdx = (m_folders.Count - 1) + 1; for (;;) { iIdx--; if (iIdx < 0) { break; } try { if (m_folders[iIdx].Path.Substring(iRootLen).Length > 0) { RscStore store = new RscStore(); store.DeleteFolder(m_folders[iIdx].Path); } m_folders.RemoveAt(iIdx); } catch (Exception /*exc*/) { } } } } if (m_files.Count == 0) { m_AppFrame.SetStatusText("Move succeeded!", StatusColoring.Success); } else { m_AppFrame.SetStatusText("Move failed for some item(s)!", StatusColoring.Error); } } else { if (m_files.Count == 0) { m_AppFrame.SetStatusText("Copy succeeded!", StatusColoring.Success); } else { m_AppFrame.SetStatusText("Copy failed for some item(s)!", StatusColoring.Error); } } //Causes exception... //ListFiles(); ActionPanel.Visibility = Rsc.Collapsed; } } break; } case "delete files_Cancel": { m_AppFrame.SetStatusText("User canceled operation!", StatusColoring.Error); break; } case "delete files": { if (e.Pos >= m_files.Count) { e.Completed = true; } else { RscFileItemDesc it = m_files[e.Pos]; string sErr = ""; try { RscStore store = new RscStore(); store.DeleteFile(it.Path); } catch (Exception exc) { sErr = "Unable to delete file.\r\n" + exc.Message; } if (sErr.Length == 0) { m_files.RemoveAt(e.Pos); if (e.Pos < m_files.Count) { int iPos = e.Pos; e.Pos = iPos; //Denie subsys to increment... } else { e.Completed = true; } } else { it.LastError = sErr; //ReQuery... lbFiles.ItemsSource = null; lbFiles.ItemsSource = m_files; if (e.Pos < (m_files.Count - 1)) { e.Max++; } else { e.Completed = true; } } } if (e.Completed) { if (m_files.Count == 0) //Otherwise error occured... { if (chbRecurse.IsChecked.Value) //Otherwise no sub-tree deletion... { int iIdx = (m_folders.Count - 1) + 1; for (;;) { iIdx--; if (iIdx < 0) { break; } try { if (m_folders[iIdx].Path.Length > 0) { RscStore store = new RscStore(); store.DeleteFolder(m_folders[iIdx].Path); } m_folders.RemoveAt(iIdx); } catch (Exception /*exc*/) { } } } } if (m_files.Count == 0) { m_AppFrame.SetStatusText("Delete succeeded!", StatusColoring.Success); // // // if (m_sAutoOperation.Length > 0) { if (m_iAutoOpPath + 1 < m_asAutoOpPathes.Length) { m_iAutoOpPath++; m_txtRootFldr.Text = m_asAutoOpPathes[m_iAutoOpPath]; m_AppFrame.AutoClick(m_btnCycle, new System.Windows.RoutedEventHandler(m_btnCycle_Click)); } else { PrepareExit(); NavigationService.GoBack(); } } // // // } else { m_AppFrame.SetStatusText("Delete failed for some item(s)!", StatusColoring.Error); } //Causes exception... //ListFiles(); ActionPanel.Visibility = Rsc.Collapsed; } break; } } }