private void btnRegistryFinder_Click(object sender, EventArgs e) { String str = "arnativ;arxml;sapicrypt;arosig;arinfo;MyRSAPKCS1SHA512SignatureDescription;pdfcreator;armgrsig;XpdfViewerCtrl"; try { str = Registry.LocalMachine.OpenSubKey(SRegistryPath) .GetValue(SRegClientRegistry, str).ToString(); } catch (Exception) { try { Registry.LocalMachine.OpenSubKey(SRegistryPath, true).SetValue(SRegClientRegistry, str); } catch (Exception ex) { MessageBox.Show(ex.Message); } } DsFileManager dsFm = new DsFileManager(txtSource.Text, txtDestination.Text) { Filters = str }; if (txtBackup.Text.Length > 0) { dsFm.RegistryFilePath = txtBackup.Text.EndsWith("\\") ? txtBackup.Text : txtBackup.Text + "\\"; dsFm.RegistryFilePath = dsFm.RegistryFilePath + "ScanClientRegistry.txt"; } else { MessageBox.Show("Please set the output path in the backup path directory. Output file name will be 'ScanClientRegistry.txt'"); return; } Thread thread = new Thread(dsFm.ScanClientRegistry); thread.Start(); while (thread.IsAlive) { Cursor.Current = Cursors.WaitCursor; Thread.Sleep(200); } Cursor.Current = Cursors.Default; DialogResult result = MessageBox.Show("Registry scan done. Output in " + dsFm.RegistryFilePath + ". Do you like to open it now?", "Registry leftovers", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Process.Start(dsFm.RegistryFilePath); } }
private void GetFilesModifiedThreaded() { DateTime from = new DateTime(); DateTime to = new DateTime(); _mFilesModified = new List <string>(); if ( GetDateFormat(dateTimePicker1.Text, out from) && GetDateFormat(dateTimePicker2.Text, out to) ) { to = to.AddDays(1); to = to.AddMilliseconds(-1); if ((to.CompareTo(from) >= 0)) { DsFileManager dsFm = new DsFileManager(txtSource.Text, txtDestination.Text); dsFm.ScanFrom = from; dsFm.ScanTo = to; dsFm.Filters = txtFilters.Text; dsFm.Excludes = txtExclude.Text; dsFm.ScanReadOnly = chkReadOnly.Checked; Thread thread = new Thread(dsFm.listModifiedFiles); thread.Start(); while (thread.IsAlive) { Cursor.Current = Cursors.WaitCursor; Thread.Sleep(200); } Cursor.Current = Cursors.Default; _mFilesModified = dsFm.FilesModified; if (_mFilesModified.Count > 100) { DateTime earliestTime = DateTime.Now; long time = 0; int filesCount = 0; foreach (string file in _mFilesModified) { FileInfo info = new FileInfo(file); time += info.LastWriteTime.Ticks / _mFilesModified.Count; if (earliestTime.CompareTo(info.LastWriteTime) > 0) { earliestTime = info.LastWriteTime; } filesCount++; } DateTime avgDateTime = new DateTime().AddTicks(time); if (MessageBox.Show( String.Format("There are many changes detected ({0}). " + "The earliest time of the files is {1} ", _mFilesModified.Count, earliestTime.ToShortDateString()) + avgDateTime.ToShortDateString(), "", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK) { _mFilesModified.Clear(); } } } } }