This is the following I have a server tcp and a client, the client has in one part of the code the following
private void SendDesktop()
{
BinaryFormatter bf = new BinaryFormatter();
ns = new NetworkStream();
ns = client.GetStream();
bf.Serialize(ns, Desktop());
}
In this part ns = new NetworkStream();
has an error that has no arguments I would like to have an argument but I do not know which one. Can someone tell me what I'm supposed to do as an argument?
If you need the code you have here
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Drawing;
using System.Net;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace DesktopClient
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
TcpClient client = new TcpClient();
NetworkStream ns = null;
int port = 0;
public Image Desktop()
{
Rectangle bounds = new Rectangle();
Bitmap Screenshot = null;
Graphics graph = null;
bounds = Screen.PrimaryScreen.Bounds;
Screenshot = new Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
graph = Graphics.FromImage(Screenshot);
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy);
return Screenshot;
}
private void SendDesktop()
{
BinaryFormatter bf = new BinaryFormatter();
ns = new NetworkStream();
ns = client.GetStream();
bf.Serialize(ns, Desktop());
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ConnectBtb_Click(object sender, EventArgs e)
{
port = int.Parse(PortBox.Text);
try
{
client.Connect(Ipbox.Text, port);
label3.Text = "Connected";
}
catch (Exception)
{
label3.Text = "Faild To Connect";
}
}
private void ShareBtn_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
SendDesktop();
}
}
}