public void Run() { File_info fi = null; while (true) { if (fi == null) { string cmd = this.ReceiveCmd(); if (cmd == null) { break; } this.parentForm.AddInfo_to_UI("Received: " + cmd); if (!cmd.StartsWith("Bye", StringComparison.OrdinalIgnoreCase)) { fi = new File_info(); fi.FromXML(cmd); } } else { bool flag = this.ReceiveFile(fi); if (!flag) { break; } fi = null; } } }
private void open_button_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { FileStream fs = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read); this.fileData_bts = new byte[fs.Length]; fs.Read(this.fileData_bts, 0, this.fileData_bts.Length); fs.Close(); this.filePath_textBox.Text = ofd.FileName; string fileName = ofd.FileName.Substring(ofd.FileName.LastIndexOf('\\') + 1); this.fileInfo = new File_info(fileName, this.fileData_bts.Length); File_info fi = new File_info(); string xml = this.fileInfo.ToXML(); fi.FromXML(xml); } }