Esempio n. 1
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.InitialDirectory = Application.ExecutablePath;
                dialog.Filter           = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
                dialog.FilterIndex      = 1;
                dialog.Multiselect      = false;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    Collection <FriendInfo> friends = ConfigCtrl.GetContactsFromFile(dialog.FileName);
                    if (friends == null || friends.Count == 0)
                    {
                        MessageBox.Show("读取联系人信息失败!", Constants.MSG_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    listBoxSelectorFriends.Clear();
                    listBoxSelectorFriends.AllItems = friends;
                }
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("FrmMaintainContact", ex);
            }
        }