Exemple #1
0
        /// <summary>
        /// The Button_Click_DelOldFolder
        /// </summary>
        /// <param name="sender">The sender<see cref="object"/></param>
        /// <param name="e">The e<see cref="RoutedEventArgs"/></param>
        private void Button_Click_DelOldFolder(object sender, RoutedEventArgs e)
        {
            using (WinForms.FolderBrowserDialog dlg = new WinForms.FolderBrowserDialog()) {
                string path = null;
                if (dlg.ShowDialog() == WinForms.DialogResult.OK)
                {
                    path = dlg.SelectedPath + @"\";

                    var sk  = new DeleteOldFiles();
                    int day = -1;
                    try {
                        day = Convert.ToInt32(FOldDayTextBox.Text);
                        if (day <= 0 || day >= 1000)
                        {
                            throw new Exception("Not valid days");
                        }
                        sk.Delete(day, path);
                    }
                    catch (Exception) {
                        MessageBox.Show("Not valid days", "Error",
                                        MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Drag and drop in old file folder
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Border_Drop_1(object sender, DragEventArgs e)
 {
     string[] Args = (string[])e.Data.GetData(DataFormats.FileDrop, true);
     DropOldFiles.Visibility = Visibility.Collapsed;
     foreach (var path in Args)
     {
         if (System.IO.Directory.Exists(path))
         {
             var sk  = new DeleteOldFiles();
             int day = -1;
             try {
                 day = Convert.ToInt32(FOldDayTextBox.Text);
                 if (day <= 0 || day >= 1000)
                 {
                     throw new Exception("Not valid days");
                 }
                 sk.Delete(day, path);
             }
             catch (Exception) {
                 MessageBox.Show("Not valid days", "Error",
                                 MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Download delete old files btn
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click_DownloadDelOld(object sender, RoutedEventArgs e)
        {
            var dk  = new DeleteOldFiles();
            int day = -1;

            try {
                day = Convert.ToInt32(OldDayTextBox.Text);
                if (day <= 0 || day >= 1000)
                {
                    throw new Exception("Not valid days");
                }
                dk.Delete(day, KnownFolders.GetPath(KnownFolder.Downloads));
            }
            catch (Exception) {
                MessageBox.Show("Not valid days", "Error",
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("please enter the path that you wish to copy");
            string sourcePath = Console.ReadLine();

            Console.WriteLine("now enter the destination you wish to copy it to");
            string destinationPath = Console.ReadLine();

            //Get directory info for both paths

            var sourceInfo      = new DirectoryInfo(sourcePath);
            var destinationInfo = new DirectoryInfo(destinationPath);

            CopyFiles.CopyDirectory(sourceInfo, destinationInfo);

            Console.WriteLine("Type 'D' if you want the source files deleted");

            //Delete already copied files if user proceeds
            if (Console.ReadKey().Key == ConsoleKey.D)
            {
                DeleteOldFiles.Delete(sourceInfo);
            }
        }