/// <summary> /// Outlook custom calendar path validation. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param> private void tbCalendarPath_Validating(object sender, CancelEventArgs e) { e.Cancel = Enabled && rbMSOutlook.Checked && rbCustomCalendar.Checked && (tbOutlookCalendarPath.Text.Any(x => Path.GetInvalidPathChars().Contains(x)) || String.IsNullOrWhiteSpace(tbOutlookCalendarPath.Text.Trim()) || !ExternalCalendar.OutlookCalendarExist(rbDefaultCalendar.Checked, tbOutlookCalendarPath.Text)); if (e.Cancel) { MessageBox.Show(@"A calendar at that path could not be found.", @"MS Outlook", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Outlook custom calendar path validation. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs"/> instance containing the event data.</param> private void tbCalendarPath_Validating(object sender, CancelEventArgs e) { var badChars = Path.GetInvalidPathChars(); e.Cancel = Enabled && rbMSOutlook.Checked && rbCustomCalendar.Checked && (tbOutlookCalendarPath.Text.Any(x => badChars.Contains(x)) || string.IsNullOrWhiteSpace(tbOutlookCalendarPath.Text) || !ExternalCalendar.OutlookCalendarExist(rbDefaultCalendar.Checked, tbOutlookCalendarPath.Text)); if (e.Cancel) { MessageBox.Show(Properties.Resources.ErrorNoCalendar, @"MS Outlook", MessageBoxButtons.OK, MessageBoxIcon.Error); } }