public static List <string> LoadXMLData(string tagName, string fileName) { var currentDirectory = IOFileOperation.GetCurrentExecutingLocation(); fileName = currentDirectory + "\\" + fileName; List <string> data = new List <string>(); XmlDocument xmlDoc = new XmlDocument(); XmlNodeList xmlNode; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); xmlDoc.Load(fs); //xmlDoc.ge xmlNode = xmlDoc.GetElementsByTagName(tagName); foreach (XmlNode node in xmlNode) { data.Add(node.InnerText.Trim()); } fs.Close(); return(data); }
public static List <string> LoadTextFileData(string fileName) { List <string> data = new List <string>(); var currentDirectory = IOFileOperation.GetCurrentExecutingLocation(); fileName = currentDirectory + "\\" + fileName; using (StreamReader sr = new StreamReader(fileName)) { string line = sr.ReadLine(); while (line != null && line.Length > 0) { data.Add(line.Trim()); line = sr.ReadLine(); } sr.Close(); } return(data); }
public static List <string> ReadXMLData(string tagName, string fileName) { List <string> data = new List <string>(); var currentDirectory = IOFileOperation.GetCurrentExecutingLocation(); fileName = currentDirectory + "\\" + fileName; using (XmlReader reader = XmlReader.Create(fileName)) { while (reader.Read()) { if (reader.Name.ToLower().Equals(tagName.ToLower())) { data.Add(reader.ReadInnerXml()); } } reader.Close(); } return(data); }