public static List
var retVal = new List
if (string.IsNullOrEmpty(path) || !File.Exists(path))
{
Comm.File.Log.LogError("ReadAllLines", string.Format("Could not load file: {0}", path)); return retVal; }
//StreamReader sr = null;
StreamReader sr = new StreamReader(path, Encoding.Default));
try {
sr = File.OpenText(path); while (sr.Peek() >= 0)
{
var line = sr.ReadLine();
if (discardEmptyLines && (line == null || string.IsNullOrEmpty(line.Trim())))
{
continue; }
if (line != null) { retVal.Add(doTrim ? line.Trim() : line);
}
}
}
catch (Exception ex)
{
Comm.File.Log.LogGeneralException("ReadAllLines", ex);
}
finally
{
if (sr != null) { sr.Close();
}
}
But my code is not correctly reading £, It is reading the character as ? please guide me what needs to be done to read the special character.
And My text file is::
108|25|50001408|4|6.95|£
108|25|50001392|4|5.23|£
108|25|50001385|3|5.29|£
108|25|50001378|3|14.25|£
Thanks in advance.
krisPosted Apr 1, 2014, 5:21 AM
But the below solution worked perfectly.
thanks for your help...
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
StreamReader sr = new StreamReader(fs, Encoding.Default);
VulpesPosted Mar 28, 2014, 1:19 PM