public static void ParseFile(string filename, Form1 form1) { CultureInfo info = CultureInfo.InvariantCulture; StreamReader reader = new StreamReader(filename); string[] directory = null; string line = ""; while ((line = reader.ReadLine()) != null) { if (line.Contains(DIRECTORY_OF)) { directory = line.Substring(line.IndexOf(DIRECTORY_OF) + DIRECTORY_OF.Length).Trim().Split(new char[] { '\\' }).ToArray(); } else { Match dateMatch = Regex.Match(line, REGEX_DATE_PATTERN); if (dateMatch.Success && !line.Contains("<DIR>")) { Match filenameMatch = Regex.Match(line.Trim(), REGEX_FILENAME_PATTERN, RegexOptions.RightToLeft); FILEITEM newFileItem = new FILEITEM() { folder = directory, filename = filenameMatch.Value, time = DateTime.ParseExact(dateMatch.Value, "dd/MM/yyyy hh:mm tt", info) }; files.Add(newFileItem); } } } }
public Form1() { InitializeComponent(); FILEITEM.ParseFile(FILENAME, this); FILEITEM.MakeTree(FILEITEM.files, null, treeView1, 0); treeView1.ExpandAll(); }