public void Log(string message) { Dispatcher.Invoke(delegate { RichTextBox1.AppendText(message); RichTextBox1.AppendText("\n"); }); }
public void SetText(string input) { RichTextBox1.AppendText(input + Environment.NewLine); RichTextBox1.SelectionStart = RichTextBox1.TextLength; RichTextBox1.SelectionStart = 0; RichTextBox1.ScrollToCaret(); }
private void DisplayText(object sender, EventArgs e) { RichTextBox1.AppendText(rxString); RichTextBox1.ScrollToCaret(); chart1.Series["Series1"].Points.AddXY(a, Convert.ToInt16(rxString)); a++; }
private void Window_Loaded(object sender, RoutedEventArgs e) { for (int i = 0; i < people.Length(); i++) { RichTextBox1.AppendText("Игрок " + people[i].Name + " набрал " + people[i].Sum + " очков" + "\n"); } var array = new int[0]; var pobeditel = Pobed(0, 0, array); RichTextBox1.Clear(); for (int i = 0; i < people.Length(); i++) { RichTextBox1.AppendText("Игрок " + people[i].Name + " набрал " + people[i].Sum + " очков" + "\n"); } TextBox1.Text = "Игрок " + pobeditel + " победил"; Single single = new Single(); try { single.Addbd(people); } catch { MessageBox.Show("Нет соединения"); } }
private void window_Loaded(object sender, RoutedEventArgs e) { var sbText = new StringBuilder(); var assembly = Assembly.GetEntryAssembly(); if (assembly != null) { var attributes = assembly.GetCustomAttributes(false); foreach (var attribute in attributes) { var type = attribute.GetType(); if (type == typeof(AssemblyTitleAttribute)) { var title = (AssemblyTitleAttribute)attribute; LabelAssemblyName.Content = title.Title; } if (type == typeof(AssemblyFileVersionAttribute)) { var version = (AssemblyFileVersionAttribute)attribute; LabelAssemblyVersion.Content = version.Version; } if (type == typeof(AssemblyCopyrightAttribute)) { var copyright = (AssemblyCopyrightAttribute)attribute; sbText.AppendFormat("{0}\r", copyright.Copyright); } if (type == typeof(AssemblyCompanyAttribute)) { var company = (AssemblyCompanyAttribute)attribute; sbText.AppendFormat("{0}\r", company.Company); } if (type == typeof(AssemblyDescriptionAttribute)) { var description = (AssemblyDescriptionAttribute)attribute; sbText.AppendFormat("{0}\r", description.Description); } } LabelAssembly.Content = sbText.ToString(); } // ReSharper disable VerbatimStringLiteralsWordIsNotInDictionary const string text = @"<log4net> <appender name=""RollingFileAppender"" type=""log4net.Appender.RollingFileAppender""> <file type=""log4net.Util.PatternString"" value=""c:\log\log.xml"" /> <appendToFile value=""true"" /> <datePattern value=""yyyyMMdd"" /> <rollingStyle value=""Date"" /> <layout type=""log4net.Layout.XmlLayoutSchemaLog4j""> <locationInfo value=""true"" /> </layout> </appender> <root> <level value=""DEBUG"" /> <appender-ref ref=""RollingFileAppender"" /> </root> </log4net>"; // ReSharper restore VerbatimStringLiteralsWordIsNotInDictionary RichTextBox1.AppendText(text); }
public void Log(string format, params string[] message) { Dispatcher.Invoke(delegate { RichTextBox1.AppendText(string.Format(format, message)); RichTextBox1.AppendText("\n"); }); }
private void FileDrop(object sender, DragEventArgs e) { string[] docPath = (string[])e.Data.GetData(DataFormats.FileDrop); StreamReader sr = new StreamReader(docPath[0], Encoding.Default); originalText = sr.ReadToEnd(); RichTextBox1.Document.Blocks.Clear(); RichTextBox1.AppendText(originalText); }
private void Launch_Handler(object sender, ExecutedRoutedEventArgs e) { RichTextBox1.AppendText((string)textBox.DataContext); using (System.IO.StreamWriter writer = new System.IO.StreamWriter("log.txt", true)) { writer.WriteLine("Внесено {0}: {1} ", textBox.ContextMenu, DateTime.Now.ToShortDateString() + ", время: " + DateTime.Now.ToLongTimeString()); writer.Flush(); } }
private void LoadFile(string Filename) { flag = false; StreamReader sr = new StreamReader(Filename, Encoding.Default); originalText = sr.ReadToEnd(); string temp = originalText.Substring(0, 1000); RichTextBox1.AppendText(temp); index += 1000; }
// 添加命令到richtextbox private void AddCmd(string cmd) { Action act = new Action(() => { string c = cmd + Environment.NewLine; RichTextBox1.AppendText(c); } ); this.Dispatcher.BeginInvoke(act); }
public void LogString(bool isIncoming, string text) { if (isIncoming) { RichTextBox1.AppendText(string.Format("IN : {0}{1}", text, Environment.NewLine)); } else { RichTextBox1.AppendText(string.Format("OUT : {0}{1}", text, Environment.NewLine)); } }
private void File_clicked(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); if (ofd.ShowDialog() == true) { StreamReader sr = new StreamReader(ofd.FileName, Encoding.Default); originalText = sr.ReadToEnd(); RichTextBox1.Document.Blocks.Clear(); RichTextBox1.AppendText(originalText); } }
public void listner() { try { while (ServerSocket.Connected) { byte[] buffer = new byte[2048]; int bytesReceive = ServerSocket.Receive(buffer); handleCommand(Encoding.Unicode.GetString(buffer, 0, bytesReceive)); } } catch { RichTextBox1.AppendText("\n Связь с сервером прервана"); } }
//按指定的种子Seed生成nums个随机数 private void GenerateRandomSequence(int nums, float seed) { float lastNum, nextNum; lastNum = seed; RichTextBox1.Clear(); RichTextBox1.AppendText(seed.ToString()); for (int i = 0; i < nums; i++) { nextNum = GetNextRanNumber(m, a, c, lastNum); RichTextBox1.AppendText(" ," + nextNum); lastNum = nextNum; } }
private void SendButton_Click(object sender, EventArgs e) { if (OutgoingTextBox.TextLength > 0) { RichTextBox1.SelectionColor = Color.Blue; RichTextBox1.AppendText(string.Format("({0}) Me: ", DateTime.Now.ToString("hh:mm:ss"))); RichTextBox1.SelectionColor = Color.Black; RichTextBox1.AppendText(string.Format("{0}\n", OutgoingTextBox.Text)); XmppGlobal.Messaging.SendMessage(foreign_jid, OutgoingTextBox.Text, message_type, thread_id); OutgoingTextBox.Text = string.Empty; XmppSounds.PlaySound(DefaultSounds.MessageIn); } }
private void Scrolling(object sender, MouseWheelEventArgs e) { if (flag == false) { if (e.Delta < 0) { if (index <= originalText.Length) { RichTextBox1.AppendText(originalText.Substring(index - 1000, index)); index += 1000; } } } }
//用于实现递归调用的Sub过程 private void DoRecursion(int times) { //结束条件 if (times == 0) { return; } //每次递归调用时要完成的工作 RichTextBox1.AppendText("第 " + times + " 次\n"); RichTextBox1.AppendText(Story); //递归调用,参数减一 DoRecursion(times - 1); }
private void TreeView1_AfterSelect(System.Object sender, System.Windows.Forms.TreeViewEventArgs e) { switch (TreeView1.SelectedNode.Text.ToString()) { case "حسابداری": RichTextBox1.Text = ""; RichTextBox1.AppendText(Environment.NewLine + " -> نرم افزار حسابداری"); break; case "ثبت اموال جدید": RichTextBox1.Text = ""; RichTextBox1.AppendText(Environment.NewLine + " -> کلیه اطلاعات اموال در ابتدا باید در این قسمت ثبت شوند"); break; } }
public void GotMessage(jabber.protocol.client.Message msg) { foreign_jid = msg.From; message_type = msg.Type; thread_id = msg.Thread; if (msg.Body.Trim().Length > 0) { RichTextBox1.SelectionColor = Color.Red; RichTextBox1.AppendText(string.Format("({0}) {1}: ", DateTime.Now.ToString("hh:mm:ss"), Text)); RichTextBox1.SelectionColor = Color.Black; RichTextBox1.AppendText(string.Format("{0}\n", msg.Body)); XmppSounds.PlaySound(DefaultSounds.MessageIn); } }
public void Start(string Current_text, string conditions) { // string without_spaces = RemoveWhitespace(TextBox.Text); string[] mas = conditions.Split('|'); string[] lines = Current_text.Split('.', '?', '!', '\n'); string result = ""; for (int i = 0; i < lines.Length; i++) { if (check_str_condition(lines[i], mas) == 1) { result = result + lines[i] + "\n"; } } // GC.Collect(); RichTextBox1.Document.Blocks.Clear(); RichTextBox1.AppendText(result); }
private void Filter(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (TextBox.Text == string.Empty) { flag = false; RichTextBox1.Document.Blocks.Clear(); RichTextBox1.AppendText(currentText); } else { if (!flag) { currentText = GetText(RichTextBox1); } Start(currentText); flag = true; } } }
private void ReportButton_Click(object sender, System.EventArgs e) { try { string line; //string path = Application.StartupPath + "log.txt"; //string[] readText = File.ReadAllLines(path); //IList<String> dataStrings = new List<String>(); //foreach (string s in readText) //{ // dataStrings.Add(s); //} //if (readText.Length == 0) //{ // dataStrings.Add("No Login information to show."); //} //dataGridView.DataSource = dataStrings.Select(x => new { Value = x }).ToList(); //dataGridView.Show(); using (StreamReader sr = new StreamReader("log.txt")) { while ((line = sr.ReadLine()) != null) { RichTextBox1.AppendText(line); RichTextBox1.AppendText("\r\n"); line = sr.ReadLine(); } sr.Close(); } } catch (Exception) { MessageBox.Show("The file could not be read or there is no data."); } }
//用于实现递归调用 private void DoRecursion(int times) { //结束条件 if (times == 0) { return; } //递归调用,参数减一 DoRecursion(times - 1); //每次递归调用时要完成的工作 //to do: 如果将以下这两句移到DoRecursion()一句之后, // 会发生什么? RichTextBox1.AppendText("第 " + times + " 次\n"); RichTextBox1.AppendText(Story); ////递归调用,参数减一 //DoRecursion(times - 1); //////每次递归调用时要完成的工作 //RichTextBox1.AppendText("第 " + times + " 次\n"); //RichTextBox1.AppendText(Story); }
public void handleCommand(string cmd) { string[] commands = cmd.Split('#'); // разбираем строку int countCommands = commands.Length; // количество for (int i = 0; i < countCommands; i++) // перебираем { try { string currentCommand = commands[i]; if (currentCommand.Contains("msg")) { string[] Arguments = currentCommand.Split('|'); AddMessage(Arguments[1]); continue; } if (currentCommand.Contains("userlist")) { Dispatcher.Invoke(new Action(() => { string[] Users = currentCommand.Split('|')[1].Split(','); // получаем массив логинов пользователей Images.Clear(); // очищаем колекцию for (int j = 0; j < Users.Length; j++) // перебираем массив пользователей { string pathAva = Environment.CurrentDirectory.ToString() + @"\img4.png"; // формируем путь к своей аватарке if (!string.IsNullOrEmpty(Users[j])) { Images.Add(new UsersChat(Users[j], pathAva, CompName)); } } ListView1.ItemsSource = Images; // коллекцию в ЛистView })); } } catch (Exception exp) { RichTextBox1.AppendText("\n ошибка: " + exp.Message); } } }
private void Verificare(object sender, RoutedEventArgs e) { string fisier; Process cmd = new Process(); string[] linkuri = { "https://raw.githubusercontent.com/Far0/Clip-scrapper/master/script_vers.info", "https://raw.githubusercontent.com/Far0/Clip-scrapper/master/app.info", "https://raw.githubusercontent.com/Far0/Clip-scrapper/master/updater.py", "https://raw.githubusercontent.com/Far0/Clip-scrapper/master/scrapper.py", "https://raw.githubusercontent.com/Far0/Clip-scrapper/master/downloader.py" }; /// linkuri(0) - versiune script; linkuri(1) - versiune aplicatie; linkuri(2) updater; linkuri(3) scrapper; linkuri(4) downloader double[] versiune = new double[2]; ///versiune(0) - script; versiune(1) aplicatie; string[] scripturi = new string[3]; string[] scripturi_nume = { "updater", "scrapper", "downloader" }; string[] modul = { "requests", "dpath", "openpyxl" }; string locatie = "Resurse/"; ProcessStartInfo argument = new ProcessStartInfo("cmd.exe", "/c py -m pip install " + modul[0] + " > " + modul[0] + ".info && py -m pip install " + modul[1] + " > " + modul[1] + ".info && py -m pip install " + modul[2] + " > " + modul[2] + ".info"); WebClient web = new WebClient(); Label3.Content = "Versiune aplicație: " + Properties.Settings.Default.aplicatie + Environment.NewLine + "Versiune script-uri: " + Properties.Settings.Default.scripturi; System.IO.Directory.CreateDirectory("Resurse"); for (int i = 0; i <= linkuri.Length - 1; i++) { StreamReader browser = new StreamReader(web.OpenRead(linkuri[i])); if (1 >= i) { double z = double.Parse(browser.ReadToEnd()); versiune[i] = z; } else { string zz = browser.ReadToEnd(); scripturi[i - 2] = zz; } if (i == linkuri.Length - 1) { browser.Close(); } } if (Properties.Settings.Default.testul_1 == 0) { Process.Start("cmd", "/c py --version > python_versiune.info"); System.Threading.Thread.Sleep(1500); fisier = File.ReadAllText("python_versiune.info"); if (fisier.Contains("Python")) { RichTextBox1.AppendText(Environment.NewLine + "[STAGE 1] Python este deja instalat."); Properties.Settings.Default.testul_1 = 1; File.Delete("python_versiune.info"); } else { Process.Start("https://www.python.org/ftp/python/3.7.4/python-3.7.4.exe"); MessageBox.Show("[STAGE 1] Nu ai Python 3.7 instalat!"); Close(); } } else { RichTextBox1.AppendText(Environment.NewLine + "[STAGE 1] Python este deja instalat."); } if (Properties.Settings.Default.aplicatie >= versiune[1]) { if (Properties.Settings.Default.aplicatie > versiune[1]) { RichTextBox1.AppendText(Environment.NewLine + "[UPDATER] Ai o versiune BETA de Night Scrapper."); Properties.Settings.Default.BETA = 1; } else { RichTextBox1.AppendText(Environment.NewLine + "[UPDATER] Ai deja ultima versiune de Night Scrapper."); } } else { MessageBox.Show("Apasă ok pentru a descărca ultima versiune de Night Scrapper.", "Night Scrapper"); if (File.Exists(scripturi_nume[0] + ".py")) { fisier = File.ReadAllText(scripturi_nume[0] + ".py"); if (scripturi[0] != fisier) { File.Delete(scripturi_nume[0] + ".py"); File.WriteAllText(scripturi_nume[0] + ".py", scripturi[0]); Process.Start("cmd", "/c py " + scripturi_nume[0] + ".py"); Close(); } } else { RichTextBox1.AppendText(Environment.NewLine + "[UPDATER] Nu am gasit " + scripturi_nume[0] + ".py, se descarcă."); File.WriteAllText(scripturi_nume[0] + ".py", scripturi[0]); Process.Start("cmd", "/c py " + scripturi_nume[0] + ".py"); Close(); } } if ((Properties.Settings.Default.testul_1 == 1) && (Properties.Settings.Default.testul_2 == 0)) { cmd.StartInfo = argument; cmd.Start(); cmd.WaitForExit(); for (int i = 0; i < modul.Length; i++) { fisier = File.ReadAllText(modul[i] + ".info"); if (fisier.StartsWith("Requirement")) { RichTextBox1.AppendText(Environment.NewLine + "[STAGE 2] Modulul " + modul[i] + " este deja instalat."); } else { RichTextBox1.AppendText(Environment.NewLine + "[STAGE 2] Modulul " + modul[i] + " s-a instalat."); } try { File.Delete(modul[i] + ".info"); } catch { RichTextBox1.AppendText(Environment.NewLine + "[INFO] Nu am găsit log file-ul " + modul[i] + ".info."); } if (i == modul.Length - 1) { Properties.Settings.Default.testul_2 = 1; } } } else { RichTextBox1.AppendText(Environment.NewLine + "[STAGE 2] Toate modulele necesare sunt deja instalate."); } for (int i = 1; i <= 2; i++) { if (File.Exists(locatie + scripturi_nume[i] + ".py")) { fisier = File.ReadAllText(locatie + scripturi_nume[i] + ".py"); if (fisier != scripturi[i]) { File.Delete(locatie + scripturi_nume[i] + ".py"); File.WriteAllText(locatie + scripturi_nume[i] + ".py", scripturi[i]); } else { RichTextBox1.AppendText(Environment.NewLine + "[STAGE 3] " + scripturi_nume[i] + ".py corespunde cu cea mai recentă versiune."); } } else { RichTextBox1.AppendText(Environment.NewLine + "[STAGE 3] Nu am găsit " + scripturi_nume[i] + ".py, se descarcă..."); File.WriteAllText(locatie + scripturi_nume[i] + ".py", scripturi[i]); } } Properties.Settings.Default.scripturi = versiune[0]; Label3.Content = "Versiune aplicație: " + Properties.Settings.Default.aplicatie + Environment.NewLine + "Versiune script-uri: " + Properties.Settings.Default.scripturi; if (Properties.Settings.Default.BETA == 1) { Properties.Settings.Default.Save(); Button1.Visibility = Visibility.Visible; } Window window = new Window1(); window.Show(); }
private void Button1_Click(object sender, RoutedEventArgs e) { Properties.Settings.Default.Save(); RichTextBox1.AppendText(Environment.NewLine + Properties.Settings.Default.testul_1 + Environment.NewLine + Properties.Settings.Default.testul_2); }
private void Button_Clear_Click(object sender, RoutedEventArgs e) { this.RichTextBox1.Document.Blocks.Clear(); RichTextBox1.AppendText(Environment.NewLine); }
public void SetFileInfo(string name, RichTextBox RTB) { Label1.Content = "Do you want to save " + name + "?"; RichTextBox1.AppendText(""); }
private Boolean DownloadFiles() { String saveLocation = saveLoc.Text; string folderName = ""; List <DownloadItem> downloadItems = new List <DownloadItem>(); if (saveLocation == "") { MessageBox.Show("Please choose a directory."); return(false); } toolStripLabel1.Text = "Loading... WAIT"; toolStripProgressBar1.Value = 5; string body = GetBodyFromURL(downloadUrl.Text); File.WriteAllText(saveLocation + "/temp.html", body); if (!body.Contains("Your progress")) { return(false); } var doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(saveLocation + "/temp.html"); toolStripProgressBar1.Value = 25; toolStripLabel1.Text = "Page loaded. Fetching url"; foreach (var div in doc.DocumentNode.SelectNodes("//div[@class='page-header-headings']")) { folderName = div.InnerText.Trim(); } Uri myUri = new Uri(downloadUrl.Text); folderName = folderName + " - " + System.Web.HttpUtility.ParseQueryString(myUri.Query).Get("id"); folderName = folderName.Trim(); folderName = GetSafeFilename(folderName); if (folderName == null || folderName == "") { return(false); //very bad design? } if (Directory.Exists(saveLocation + "\\download\\" + folderName)) { MessageBox.Show("Can't download course that was already downloaded. Please delete the old folder to redownload again or choose a different location. " + saveLocation + "\\download\\" + folderName); return(false); } if (doc.DocumentNode.SelectNodes("//div[@class='course-content']") != null) { foreach (var div in doc.DocumentNode.SelectNodes("//div[@class='course-content']")) { foreach (var ul in div.Elements("ul")) { foreach (var section in ul.Elements("li")) { foreach (var itemLi in section.Descendants("li")) { foreach (var itemLink in itemLi.Descendants("a")) { if (!itemLink.GetAttributeValue("href", "nolink").Contains("resource/view.php?id")) { error += "Skipping Link: " + itemLink.GetAttributeValue("href", "nolink") + "\r\n"; continue; } if (itemLink.Element("span").HasClass("instancename")) { downloadItems.Add(new DownloadItem(itemLink.Element("span").InnerText, section.GetAttributeValue("aria-label", "all"), itemLink.GetAttributeValue("href", "nolink"))); //null changed to nolink RichTextBox1.AppendText("Found file: " + itemLink.Element("span").InnerText + " \r\n"); } } } } } } } else { MessageBox.Show("Course type not supported."); return(false); } if (downloadItems.Count < 1) { MessageBox.Show("Course type not supported."); return(false); } toolStripProgressBar1.Value = 35; toolStripLabel1.Text = "All links fetched... Now downloading... This may take a while..."; var incrementProgress = 65 / downloadItems.Count; string cookies = GetCookies(); string path = saveLocation + "\\download\\" + folderName; string historyFile = path + "\\.download_history"; List <string> history = new List <string>(); thread = new Thread(() => { foreach (var dlItem in downloadItems) { this.Invoke((MethodInvoker) delegate { toolStripProgressBar1.Value += incrementProgress; }); this.Invoke((MethodInvoker) delegate { richTextBox2.AppendText("Downloading file: " + dlItem.name + "\r\n"); }); //getBodyFromURL(dlItem.url); history.Add(dlItem.folder + "\\" + dlItem.name); DownloadInit(dlItem, cookies, path); } }); thread.IsBackground = true; thread.Start(); while (thread.IsAlive) { Application.DoEvents(); } using (TextWriter tw = new StreamWriter(historyFile)) { foreach (String s in history) { tw.WriteLine(s); } } File.Delete(saveLoc.Text + "/temp.html"); toolStripProgressBar1.Value = 0; toolStripLabel1.Text = "Completed. Saved to: " + saveLocation + "\\download\\" + folderName; return(true); }
//TODO: Merge DownloadFiles() and RefreshFiles() into one function. private Boolean RefreshFiles(string URL, string saveLocation) { if (killThread) { return(false); } List <DownloadItem> downloadItems = new List <DownloadItem>(); toolStripLabel1.Text = "Loading... WAIT"; toolStripProgressBar1.Value = 5; string body = GetBodyFromURL(URL); File.WriteAllText(saveLoc.Text + "/temp.html", body); if (!body.Contains("Your progress")) { return(false); } var doc = new HtmlAgilityPack.HtmlDocument(); doc.Load(saveLoc.Text + "/temp.html"); toolStripProgressBar1.Value = 25; toolStripLabel1.Text = "Page loaded. Fetching url"; foreach (var div in doc.DocumentNode.SelectNodes("//div[@class='page-header-headings']")) { //folderName = div.InnerText.Trim(); //TODO change folder name if the course name has changed. } if (doc.DocumentNode.SelectNodes("//div[@class='course-content']") != null) { foreach (var div in doc.DocumentNode.SelectNodes("//div[@class='course-content']")) { foreach (var ul in div.Elements("ul")) { foreach (var section in ul.Elements("li")) { foreach (var itemLi in section.Descendants("li")) { foreach (var itemLink in itemLi.Descendants("a")) { if (!itemLink.GetAttributeValue("href", "nolink").Contains("resource/view.php?id")) { error += "Skipping Link: " + itemLink.GetAttributeValue("href", "nolink") + "\r\n"; continue; } if (itemLink.Element("span").HasClass("instancename")) { downloadItems.Add(new DownloadItem(itemLink.Element("span").InnerText, section.GetAttributeValue("aria-label", "all"), itemLink.GetAttributeValue("href", "nolink"))); //null changed to nolink RichTextBox1.AppendText("Found file: " + itemLink.Element("span").InnerText + " \r\n"); } } } } } } } else { error += "Course not supported anymore. " + URL + " \r\n"; return(false); } if (downloadItems.Count < 1) { return(false); } toolStripProgressBar1.Value = 35; toolStripLabel1.Text = "All links fetched... Now downloading... This may take a while..."; var incrementProgress = 65 / downloadItems.Count; string cookies = GetCookies(); string historyFile = saveLocation + "\\.download_history"; string[] history = null; Boolean validHistory = true; if (File.Exists(historyFile)) { history = File.ReadAllLines(historyFile); } else { validHistory = false; } List <string> newHistory = new List <string>(); if (validHistory && !(history.Length > 0)) { validHistory = false; } thread = new Thread(() => { foreach (var dlItem in downloadItems) { if (killThread) { continue; } this.Invoke((MethodInvoker) delegate { toolStripProgressBar1.Value += incrementProgress; }); newHistory.Add(dlItem.folder + "\\" + dlItem.name); if (validHistory) { var index = Array.FindIndex(history, x => x == (dlItem.folder + "\\" + dlItem.name)); if (index > -1) { continue; // file already downloaded } } this.Invoke((MethodInvoker) delegate { richTextBox2.AppendText("Downloading file: " + dlItem.name + "\r\n"); }); //getBodyFromURL(dlItem.url); DownloadInit(dlItem, cookies, saveLocation); } }); thread.IsBackground = true; thread.Start(); while (thread.IsAlive) { Application.DoEvents(); } using (TextWriter tw = new StreamWriter(historyFile)) { foreach (String s in newHistory) { tw.WriteLine(s); } } File.Delete(saveLoc.Text + "/temp.html"); return(true); }