.NET - Čtení souboru z disku
08.07.2012
Potřebuji přečíst obsah souboru na disku. Lze použít následující kod.
try {
Encoding encode = Encoding.GetEncoding("utf-8");
using (FileStream fs = new FileStream(soubor, FileMode.Open, FileAccess.Read, FileShare.Read))
{
using (StreamReader sw = new StreamReader(fs, encode))
{
string line;
while ((line = sw.ReadLine()) != null)
{
// process line
}
}
}
}
catch {
// process error
}
