0
is the following I have a server tcp and a client, the client has in a 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 put an argument but do not know which one. someone can tell me what I am supposed to put as argument?
If you need your own code 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();
}
}
}
We do not know either, after all the code is yours, but whenever you have doubts about how to use a method, just consult the documentation: https://msdn.microsoft.com/en-us/library/system.net.sockets.networkstream(v=vs.110). aspx
– Maniero
Look at this question
– Marco Souza