private void userButton2_Click(object sender, EventArgs e) { // 删除选中文件 TreeNode treeNode = treeView1.SelectedNode; if (treeNode.Name != "files_root") { // 删除文件前要先进行密码验证 using (FormPasswordCheck passwordCheck = new FormPasswordCheck(UserClient.UserAccount.Password)) { if (passwordCheck.ShowDialog() == DialogResult.OK) { // 密码验证已经通过 OperateResult result = UserClient.Net_File_Client.DeleteFile( treeNode.Text, "Files", "Personal", UserClient.UserAccount.UserName); if (result.IsSuccess) { // 更新文件列表 DownloadUserFileNames(); } else { MessageBox.Show("删除失败,原因:" + result.Message); } } } } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { //密码验证的示例,此处关闭窗口验证 using (FormPasswordCheck fpc = new FormPasswordCheck("123456")) { if (fpc.ShowDialog() == DialogResult.OK) { IsWindowShow = false; Thread.Sleep(20); //关闭网络引擎 net_socket_server.ServerClose(); net_simplify_server.ServerClose(); net_udp_server.ServerClose(); } else { //取消关闭 e.Cancel = true; } } //紧急数据的保存已经放置到dispose方法中,即时发生BUG或直接关机,也能存储数据 }