public bool Equals(FileCommunicationObject other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.File.Equals(other.File));
 }
        public static FileCommunicationObject ByteArrayToFile(byte[] data)
        {
            int[] splitIdx = new int[2];
            int   idx      = 0;

            for (int i = 1; i < data.Length; i++)
            {
                if (data[i] == Encoding.UTF8.GetBytes("|")[0])
                {
                    splitIdx[idx++] = i;
                }
                if (idx == 2)
                {
                    break;
                }
            }
            byte[] chatNum    = new byte[4];
            byte[] senderName = new byte[splitIdx[0] - 5];
            byte[] fileName   = new byte[splitIdx[1] - splitIdx[0] - 1];
            byte[] file       = new byte[data.Length - splitIdx[1] - 1];
            idx = 0;
            for (int i = 0; i < 4; i++)
            {
                chatNum[idx++] = data[i + 1];
            }
            idx = 0;
            for (int i = 5; i < splitIdx[0]; i++)
            {
                senderName[idx++] = data[i];
            }
            idx = 0;
            for (int i = splitIdx[0] + 1; i < splitIdx[1]; i++)
            {
                fileName[idx++] = data[i];
            }
            idx = 0;
            for (int i = splitIdx[1] + 1; i < data.Length; i++)
            {
                file[idx++] = data[i];
            }
            FileCommunicationObject result = new FileCommunicationObject()
            {
                ChatNum  = BitConverter.ToInt32(chatNum, 0),
                Sender   = Encoding.UTF8.GetString(senderName),
                FileName = Encoding.UTF8.GetString(fileName),
                File     = file
            };

            return(result);
        }