Esempio n. 1
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            logBlock.Text = "Searching for " + textBox.Text + "\r\n";
            var listing = onlyListing.IsChecked.Value;
            var obj     = new CopyFilesNative.CopyFileIterator(textBox.Text, listing);

            textBox.IsEnabled = false;
            button.IsEnabled  = false;
            int    totalFileNumber = 0;
            UInt64 totalFileSize   = 0;
            var    operation       = (listing) ? "Found " : "Copied ";

            try
            {
                while (true)
                {
                    var foundFile = await Task.Run(() => FindNextFile(obj));

                    if (foundFile == "")
                    {
                        break;
                    }
                    logBlock.Text += operation + foundFile + "\r\n";
                    scrollViewer.ChangeView(0, double.MaxValue, 1, true);
                    totalFileSize += obj.GetLastFileSize();
                    totalFileNumber++;
                }
                logBlock.Text += string.Format(
                    "{0}{1} file(s). Total {2} KB.",
                    operation, totalFileNumber, totalFileSize / 1024);
                scrollViewer.UpdateLayout();
                scrollViewer.ChangeView(0, double.MaxValue, 1);
            }
            finally
            {
                button.IsEnabled  = true;
                textBox.IsEnabled = true;
            }
        }
Esempio n. 2
0
 private async void button_Click(object sender, RoutedEventArgs e)
 {
     logBlock.Text = "Searching for " + textBox.Text + "\r\n";
     var listing = onlyListing.IsChecked.Value;
     var obj = new CopyFilesNative.CopyFileIterator(textBox.Text, listing);
     textBox.IsEnabled = false;
     button.IsEnabled = false;
     int totalFileNumber = 0;
     UInt64 totalFileSize = 0;
     var operation = (listing) ? "Found " : "Copied ";
     try
     {
         while (true)
         {
             var foundFile = await Task.Run(() => FindNextFile(obj));
             if (foundFile == "")
             {
                 break;
             }
             logBlock.Text += operation + foundFile + "\r\n";
             scrollViewer.ChangeView(0, double.MaxValue, 1, true);
             totalFileSize += obj.GetLastFileSize();
             totalFileNumber++;
         }
         logBlock.Text += string.Format(
             "{0}{1} file(s). Total {2} KB.",
             operation, totalFileNumber, totalFileSize / 1024);
         scrollViewer.UpdateLayout();
         scrollViewer.ChangeView(0, double.MaxValue, 1);
     }
     finally
     {
         button.IsEnabled = true;
         textBox.IsEnabled = true;
     }
 }
Esempio n. 3
0
 private string FindNextFile(
     CopyFilesNative.CopyFileIterator obj)
 {
     return(obj.NextFile());
 }