Here is a little function, that might help or at least to have another approach, it is super basic and no error control was used:
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
[CommandMethod("ReadFile2")]
public void ReadFile2()
{
string sFileName = "c:\\test.txt";
FileStream stream = null;
stream = File.OpenRead(sFileName);
byte[] text = new byte[stream.Length];
stream.Read(text, 0, (int)stream.Length);
stream.Close();
ASCIIEncoding encoding = new ASCIIEncoding();
string content = encoding.GetString(text);
// string pattern = "[*]";
string pat = @"\w+\b-\b\w+"; // this will find the word characters between "-"...
// for some reason I cannot get the split to work where this character is used: "¦", I need to read more about expressions
MatchCollection matches = Regex.Matches(content,pat);
foreach(Match match in matches)
{
CommandLinePrompts.Message(match.Value);
}
}
Hope that helps, I am also learning C#