private void BtnSetClick_Click(object sender, RoutedEventArgs e) { RtbResult.AppendText("正在写入\r"); try { List <string> ChildPath = new List <string>(Directory.GetDirectories(_JdkPath)); string JrePath = System.IO.Path.Combine(_JdkPath, "jre"); string BinPath = System.IO.Path.Combine(_JdkPath, "bin"); string LibPath = System.IO.Path.Combine(_JdkPath, "lib"); if (ChildPath.Contains(JrePath) && ChildPath.Contains(BinPath) && ChildPath.Contains(LibPath)) { _JavaHome = _JdkPath; Environment.SetEnvironmentVariable("JAVA_HOME", _JavaHome, EnvironmentVariableTarget.Machine); RtbResult.AppendText("JAVA_HOME写入成功\r"); Environment.SetEnvironmentVariable("CLASSPATH", _ClassPath, EnvironmentVariableTarget.Machine); RtbResult.AppendText("CLASSPATH写入成功\r"); string PathValue = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine); _PathAdded += PathValue; Environment.SetEnvironmentVariable("Path", _PathAdded, EnvironmentVariableTarget.Machine); } else { RtbResult.AppendText("写入失败\r"); } } catch (Exception ex) { RtbResult.AppendText(string.Format("写入失败\r+{0}", ex.ToString())); } }
private void BtnStartSearch_OnClick(object sender, RoutedEventArgs e) { //ExecuteToStream(BtnStartSearch, () => BtnStartSearch.Visibility = Visibility.Hidden); var searchService = new SimleSearchService(); searchService.Directories.AddRange(_checkBoxsDir.Select(x => x.Tag.ToString())); searchService.SearchData = TbSearchData.Text; Task.Run(() => { var searchingResult = searchService.GetYield(); foreach (var resultStringPath in searchingResult) { ExecuteInParallelThread(RtbResult, () => RtbResult.AppendText($"{resultStringPath}{Environment.NewLine}")); } }); }