Posts

Showing posts from April, 2013

find email address in text file using c#

string data = File.ReadAllText("filepath"); //read File //instantiate with this pattern Regex emailRegex = newRegex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", RegexOptions.IgnoreCase); //find items that matches with our pattern MatchCollection emailMatches = emailRegex.Matches(data);

foreach (Match emailMatch in emailMatches)         {          String AnchorLink;             AnchorLink = "<" + "a href=" + emailMatch.Value + " style="+"text-decoration:underline"+">" + emailMatch.Value + "<a>";             lblId.Text += data.Replace(emailMatch.Value, AnchorLink);                            }

Open and read an XML file to Dataset

foreach (string file in Directory.GetFiles("write your path", "*.xml"))
            {
                if (file.Length > 0)
                {
                    dsMenu = new DataSet();
                    dsMenu.ReadXml(file);
                    DataTable dt = dsMenu.Tables[0];
                    DataTable dt2 = dsMenu.Tables[1];
                    DataTable dt3 = dsMenu.Tables[2];

                }
            }