Exemplo n.º 1
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs ex)
        {
            string           path             = "";
            BackgroundWorker worker           = sender as BackgroundWorker;
            ProgressArgument progressArgument = new ProgressArgument();

            try
            {
                var options = new EnumerationOptions()
                {
                    IgnoreInaccessible    = true,
                    RecurseSubdirectories = true
                };

                DriveInfo[] allDrives = DriveInfo.GetDrives();
                int         count     = 1;
                foreach (var drive in allDrives)
                {
                    if (worker.CancellationPending)
                    {
                        ex.Cancel = true;
                        return;
                    }
                    progressArgument.count           = count;
                    progressArgument.allDrivesLength = allDrives.Length;
                    worker.ReportProgress(10, progressArgument);

                    string[] dirs = Directory.GetFiles(drive.Name, @"Among Us.exe", options);
                    if (dirs.Length > 0)
                    {
                        path      = dirs[0].Replace("\\Among Us.exe", "");
                        ex.Result = path;
                        return;
                    }
                    count++;
                }
            }
            catch (Exception e)
            {
                Logger.Log(null, e);
            }
        }
Exemplo n.º 2
0
        private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            ProgressArgument progressArgument = (ProgressArgument)e.UserState;

            this.mainWindow.LabelProcessedDrives.Text = "Searching in drive " + progressArgument.count + " of " + progressArgument.allDrivesLength;
        }