static void Main(string[] args) { Data data = new Data(); using (FileStream fileStream = new FileStream(@"SoapData.txt", FileMode.OpenOrCreate, FileAccess.Write)) { SoapFormatter soapFormatter = new SoapFormatter(); soapFormatter.Serialize(fileStream, data); fileStream.Close(); } }
private void button1_Click(object sender, EventArgs e) { Data data = new Data(); data.PrivateData = textBox1.Text; data.publicData = textBox2.Text; label3.Text = "Connecting..."; try { NetworkStream networkStream = Client.Connect(); SoapFormatter formatter = new SoapFormatter(); formatter.Serialize(networkStream, data); networkStream.Close(); label3.Text = "Data sent"; button1.Enabled = false; } catch (SocketException se) { label3.Text = se.Message; button1.Enabled = true; } }