Пример #1
0
        /// <summary>
        /// It handles the formclosing event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Server_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (MessageBox.Show("Are you sure ? ", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
                {
                    e.Cancel = true;
                }
                else
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load("MyConfig.xml");
                    XmlElement root = doc.DocumentElement;

                    string          userName = root.Attributes["username"].Value;
                    int             port     = int.Parse(root.Attributes["port"].Value);
                    string          ip       = root.Attributes["ip"].Value;
                    DBServiceClient srv      = new DBServiceClient();
                    srv.removeUserFromOnlineUsersTable(userName, port, ip);
                    if (Server != null)
                    {
                        Server.Disconnect(MachineInfo.GetJustIP());
                    }
                    e.Cancel = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "FTP File Sharing", MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.Cancel = false;
            }
        }
Пример #2
0
 /// <summary>
 /// It handles the formclosing event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Server_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         if (MessageBox.Show("Are you sure ? ", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
         {
             e.Cancel = true;
         }
         else
         {
             if (Server != null)
             {
                 Server.Disconnect(MachineInfo.GetJustIP());
             }
             e.Cancel = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "FTP File Sharing", MessageBoxButtons.OK, MessageBoxIcon.Error);
         e.Cancel = false;
     }
 }