I could solve this issue. Apparently it was an error with the Length of the string passed.
I initialized my byte array like this:
byte[] array = new byte[strBuffer.Length];
The problem is that the string.Length wasn't accurate. If I initialize the Byte array implicit then the problem doesn't occur.
byte[] array = Encoding.ASCII.GetBytes(strBuffer);
Thanks for the support. I hope this helps other people trying to solve the issue.
Following is the new code:
FileStream fs = new FileStream(strFilePath, FileMode.Open); StreamReader reader = new StreamReader(fs); string strBuffer = reader.ReadToEnd(); reader.Close(); strBuffer = PrinterHelper.FillTestInformations(strBuffer); byte[] array = Encoding.ASCII.GetBytes(strBuffer); client = new TcpClient(AddressFamily.InterNetwork); client.Connect(IPAddress.Parse(strIP), nPort); client.GetStream().Write(array, 0, array.Length); client.Close();