private void OutputToTextBox(string log) { //if (TBLog.GetLineFromCharIndex(TBLog.Text.Length) > 100) // TBLog.Text = ""; TBLog.AppendText(DateTime.Now.ToString("HH:mm:ss ") + log + "\r\n"); }
void AtualizaJanela(object sender, EventArgs e) { if (ServidorON == true) { BTConectaAoServidor.IsEnabled = false; BTDesconectaDoServidor.IsEnabled = true; TBEnvia.IsEnabled = true; BTEnvia.IsEnabled = true; } else { BTConectaAoServidor.IsEnabled = true; BTDesconectaDoServidor.IsEnabled = false; TBEnvia.IsEnabled = false; BTEnvia.IsEnabled = false; if (tx != null && receptor != null) { tx.Close(); receptor.Interrupt(); } } if (linhaAtual < linhas.Count()) { for (int i = linhaAtual; i < linhas.Count(); i++) { TBLog.AppendText(linhas[i] + '\n'); linhaAtual++; } TBLog.ScrollToEnd(); } }
public void AppendLog(string text) { Dispatcher.Invoke(() => { TBLog.AppendText(text + Environment.NewLine); TBLog.ScrollToEnd(); }); }
void AtualizaJanela(object sender, EventArgs e) { if (linhaAtual < linhas.Count()) { for (int i = linhaAtual; i < linhas.Count(); i++) { TBLog.AppendText(linhas[i] + '\n'); linhaAtual++; } TBLog.ScrollToEnd(); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { excelApp = new Microsoft.Office.Interop.Excel.Application(); excelApp.Visible = true; workbook1 = excelApp.Workbooks.Open(filepath.Text); worksheet1 = workbook1.ActiveSheet; while (!Equals(((Range)worksheet1.Cells[n, 1]).Text, "")) { string a = ((Range)worksheet1.Cells[n, 1]).Text; names.Add(a); n++; } TBLog.Clear(); foreach (var name in names) { var temp = false; foreach (var file in AllFileNames) { if (file.Contains(name)) { //FileInfo fi1 = new FileInfo(file); // fi1.CopyTo(TBTargetFolderPath+@"\" + System.IO.Path.GetFileName(file)); var a = System.IO.Path.GetFileName(file); var b = TBTargetFolderPath.Text + @"\" + a; System.IO.File.Copy(file, b, true); temp = true; } } if (!temp) { i++; TBLog.AppendText(i + ":" + name + "未找到\n"); //System.Windows.MessageBox.Show(i + ":" + name + "未找到\n"); } } }