Nie wiem co się dzieje, mam taka klasę:
public class Sender
{
private string stringToFile;
private string IPA;
private int PortN;
public Sender(string stringToFile, string IPA, int PortN)
{
this.stringToFile = stringToFile;
this.IPA = IPA;
this.PortN = PortN;
}
public void method()
{
}
public void SendTCP()
{
int BufferSize = 1024;
byte[] SendingBuffer = null;
TcpClient client = null;
// lblStatus.Content = "";
NetworkStream netstream = null;
try
{
client = new TcpClient(IPA, PortN);
//lblStatus.Content = "Connected to the Server...\n";
netstream = client.GetStream();
FileStream Fs = new FileStream(stringToFile, FileMode.Open, FileAccess.Read);
int NoOfPackets = Convert.ToInt32
(Math.Ceiling(Convert.ToDouble(Fs.Length) / Convert.ToDouble(BufferSize)));
int TotalLength = (int)Fs.Length, CurrentPacketLength;
for (int i = 0; i < NoOfPackets; i++)
{
if (TotalLength > BufferSize)
{
CurrentPacketLength = BufferSize;
TotalLength = TotalLength - CurrentPacketLength;
}
else
CurrentPacketLength = TotalLength;
SendingBuffer = new byte[CurrentPacketLength];
Fs.Read(SendingBuffer, 0, CurrentPacketLength);
netstream.Write(SendingBuffer, 0, (int)SendingBuffer.Length);
}
//lblStatus.Content = lblStatus.Content + "Sent " + Fs.Length.ToString() + "bytes to the server";
Fs.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (netstream != null)
netstream.Close();
if (client != null)
client.Close();
}
}
}
I nie mam dostępu do publicznych metod:
Coś mi umyka czy to coś nie tak z VS?