public bool WriteData(byte[] Data) { bool success = false; if (this.IsConnected) { try { int outputReportByteLength = myUSB.HidpCaps.OutputReportByteLength; int bytesSend = 1; //if bWriteData is bigger then one report diveide into sevral reports while (bytesSend < Data.Length) { // Set the size of the Output report buffer. // byte[] OutputReportBuffer = new byte[myUSB.myHIDP_CAPS.OutputReportByteLength - 1 + 1]; byte[] OutputReportBuffer = new byte[outputReportByteLength]; // set the report id OutputReportBuffer[0] = Data[0]; // Store the report data following the report ID. for (int i = 1; i < OutputReportBuffer.Length; i++) { if (bytesSend < Data.Length) { OutputReportBuffer[i] = Data[bytesSend]; bytesSend++; } else { OutputReportBuffer[i] = 0; } } success = myUSB.CT_WriteFile(OutputReportBuffer); } } catch (Exception ex) { success = false; } } else { success = false; } return(success); }