private async void Validator(string _share, string _permlevel) { if (await Task.Run(() => Directory.Exists(_share))) { BtnNext.Enabled = true; lblValidation.BackColor = Color.FromArgb(40, 40, 40); lblValidation.ForeColor = Color.GreenYellow; lblValidation.Text = "Valid Share"; if (_share.Length >= 15) { try { NameSuggester ns = new NameSuggester(_share, _permlevel); txtBoxSuggestion.Text = ns.suggestName(); } catch (Exception ex) { statusLbl.Text = ex.Message; } } else { txtBoxSuggestion.Text = ""; } } else { BtnNext.Enabled = false; lblValidation.BackColor = Color.FromArgb(40, 40, 40); lblValidation.ForeColor = Color.Orange; lblValidation.Text = "Invalid Share"; txtBoxSuggestion.Text = ""; ImageReset(); } if (String.IsNullOrWhiteSpace(_share)) { lblValidation.Text = ""; lblValidation.BackColor = Color.WhiteSmoke; txtBoxSuggestion.Text = ""; lstBoxPreview.BackColor = Color.WhiteSmoke; lstBoxPreview.Items.Clear(); } }
private void Validator(string _share, string _permlevel) { if (Directory.Exists(_share)) { lblValidation.BackColor = Color.FromArgb(40, 40, 40); lblValidation.ForeColor = Color.GreenYellow; lblValidation.Text = "Valid Share"; if (_share.Length >= 15) { try { NameSuggester ns = new NameSuggester(_share, _permlevel); txtBoxSuggestion.Text = ns.suggestName(); } catch (Exception ex) { statusLbl.Text = ex.Message; } } else { txtBoxSuggestion.Text = ""; } } else { lblValidation.BackColor = Color.FromArgb(40, 40, 40); lblValidation.ForeColor = Color.Orange; lblValidation.Text = "Invalid Share"; txtBoxSuggestion.Text = ""; } if (String.IsNullOrWhiteSpace(_share)) { lblValidation.Text = ""; lblValidation.BackColor = Color.WhiteSmoke; txtBoxSuggestion.Text = ""; } }