private void btnSave_ServerClick(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } if (mcImportFile.PostedFile != null && mcImportFile.PostedFile.ContentLength > 0) { string sText = string.Empty; using (StreamReader _reader = new StreamReader(mcImportFile.PostedFile.InputStream)) { sText = _reader.ReadToEnd(); } string regex = "([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\\w]*[0-9a-zA-Z])*\\.)+[a-zA-Z]" + "{2,9})"; System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline) | System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options); foreach (Match item in reg.Matches(sText)) { if (ListType == "Black" && !BlackListItem.Contains(item.Value)) { BlackListItem.Create(item.Value); } if (ListType == "White" && !WhiteListItem.Contains(item.Value)) { WhiteListItem.Create(item.Value); } } } Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "try {window.opener.location.href=window.opener.location.href;}" + "catch (e){} window.close();", true); }