Esempio n. 1
0
        //打包想要的json信息
        private string MakeUserPacket(MessageID id, List<SharedFilesTo> files)
        {
            var message = new Message()
            {
                ID = id,
                user = Hoster,
                sharedfiles = files,
                sharedpassword = DownPassword
            };
            var serializer = new DataContractJsonSerializer(typeof(Message));
            var stream = new MemoryStream();
            serializer.WriteObject(stream, message);

            byte[] dataBytes = new byte[stream.Length];

            stream.Position = 0;

            stream.Read(dataBytes, 0, (int)stream.Length);

            string dataString = Encoding.UTF8.GetString(dataBytes);

            return dataString;
        }
Esempio n. 2
0
        //打包想要的json信息
        private string MakeUserPacket(MessageID id,int index)
        {
            var message = new Message()
            {
                ID = id,
                user = Hoster,
                font = MyFont,
                fileid = index
            };
            var serializer = new DataContractJsonSerializer(typeof(Message));
            var stream = new MemoryStream();
            serializer.WriteObject(stream, message);

            byte[] dataBytes = new byte[stream.Length];

            stream.Position = 0;

            stream.Read(dataBytes, 0, (int)stream.Length);

            string dataString = Encoding.UTF8.GetString(dataBytes);

            return dataString;
        }