XML=>
var Info = XDocument.Load(completeFilePath);
var descendants = employeeInfo.Descendants("Element");
var list = new List<Employee>();
foreach (var descendant in descendants)
{
var emp = new Employee();
emp.EmployeeId= descendant.Element("Id").Value;
emp.Name = descendant.Element("Name").Value;
list.Add(emp);
}
Text=>
var fileInLines = File.ReadAllLines(completeFilePath);
foreach (var line in fileInLines)
{
var fileAttributes = line.Split(' ');
var emp = new Employee();
emp.Id = fileAttributes[0];
emp.Name = fileAttributes[1];
list.Add(emp);
}
CSV=>
StreamWriter cfile = new StreamWriter(filepath);
using (var wc = cfile)
{
var sb = new StringBuilder();
foreach (var emp in employees)
{
sb.Append(emp.Id + ",");
sb.Append(emp.Name + ",");
}
wc.WriteLine(sb.ToString());
}
var Info = XDocument.Load(completeFilePath);
var descendants = employeeInfo.Descendants("Element");
var list = new List<Employee>();
foreach (var descendant in descendants)
{
var emp = new Employee();
emp.EmployeeId= descendant.Element("Id").Value;
emp.Name = descendant.Element("Name").Value;
list.Add(emp);
}
Text=>
var fileInLines = File.ReadAllLines(completeFilePath);
foreach (var line in fileInLines)
{
var fileAttributes = line.Split(' ');
var emp = new Employee();
emp.Id = fileAttributes[0];
emp.Name = fileAttributes[1];
list.Add(emp);
}
CSV=>
StreamWriter cfile = new StreamWriter(filepath);
using (var wc = cfile)
{
var sb = new StringBuilder();
foreach (var emp in employees)
{
sb.Append(emp.Id + ",");
sb.Append(emp.Name + ",");
}
wc.WriteLine(sb.ToString());
}
No comments:
Post a Comment