private void saveDataFileDialog_FileOk(object sender, CancelEventArgs e) { string path = this.saveDataFileDialog.FileName; FileStream fileStream = new FileStream(path, FileMode.Create); byte[] serBytes; ToBytes <BookDetailList> .GetBytes(ref BookList, out serBytes); fileStream.Write(serBytes, 0, serBytes.Length); fileStream.Flush(); fileStream.Close(); fileStream.Dispose(); }
private void SaveConstData(string path) { FileStream fileStream = new FileStream(path, FileMode.Create); byte[] serBytes; BookCosting reff = Cost; ToBytes <BookCosting> .GetBytes(ref reff, out serBytes); fileStream.Write(serBytes, 0, serBytes.Length); fileStream.Flush(); fileStream.Close(); fileStream.Dispose(); }
private void OnDispaly() { // 加载用户 foreach (var client in players.__table.ToList()) { string uac = client.Key; string ucl = client.Value.client.name; facebook.Add(ucl, uac); listBox_Allow.Items.Add(ucl); } // 准备 Byte[] 数据 final.Data = books; ToBytes <BookInformationList> .GetBytes(ref final, out data); }
/// <summary> /// 存储新的用户登录信息 /// </summary> /// <param name="path">文件路径</param> private void SaveUsersData(string path) { FileStream fileStream = new FileStream(path, FileMode.Create); byte[] serBytes; ToBytes <UserSet> .GetBytes(ref users, out serBytes); string longkey = Cipher.getInitVector(24); string key = longkey.Substring(0, 16); string iv = longkey.Substring(16, 8); byte[] cipher = Cipher.AESEncrypt(serBytes, key, iv); fileStream.Write(cipher, 0, cipher.Length); fileStream.Flush(); fileStream.Close(); fileStream.Dispose(); Registry.AddKey2Registry("PublishServer\\Encrypt", "SecretKey", key); Registry.AddKey2Registry("PublishServer\\Encrypt", "InitVector", iv); }
private void tSMI_Sendto_Click(object sender, EventArgs e) { BookEvaluaionList data = new BookEvaluaionList(); for (int i = 0, sz = listView_Books.SelectedItems.Count; i < sz; i++) { string id = listView_Books.SelectedItems[i].SubItems[0].Text; BookEvaluaion tmp = new BookEvaluaion(); BookEval.tryFind(int.Parse(id), out tmp); data.Add(tmp); } byte[] raw; ToBytes <BookEvaluaionList> .GetBytes(ref data, out raw); TcpClientP home = new TcpClientP(); home.Connect(new IPEndPoint(serverIP, Port.TCP_BOOK_EVALUATION_PORT)); home.Write(raw); home.Close(); MessageBox.Show("发送成功", "提示", MessageBoxButtons.OK); }