Skip to content

Instantly share code, notes, and snippets.

@nelopauselli
Created July 13, 2012 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelopauselli/3104211 to your computer and use it in GitHub Desktop.
Save nelopauselli/3104211 to your computer and use it in GitHub Desktop.
Clase responsable de la lectura de archivos
internal class MyFileReader
{
public void ReadFile(string fileName, Action<string, string, string, string> callback)
{
using (var fs = new FileStream(fileName, FileMode.Open))
{
var reader = XmlReader.Create(fs);
while (reader.Read())
{
if (reader.Name != "product") continue;
var id = reader.GetAttribute("id");
var name = reader.GetAttribute("name");
var unitPrice = reader.GetAttribute("unitPrice");
var discontinued = reader.GetAttribute("discontinued");
callback(id, name, unitPrice, discontinued);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment