From 6f43c8a76badf223d1f51d6befa26f753a8ddd31 Mon Sep 17 00:00:00 2001 From: BlubbFish Date: Mon, 19 Apr 2010 11:18:26 +0000 Subject: [PATCH] =?UTF-8?q?Ini=20Dateien=20leser=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NetMonitorCliend/InIReader.cs | 50 ++++++++++++++++++++++++ NetMonitorCliend/NetMonitorCliend.csproj | 2 + 2 files changed, 52 insertions(+) create mode 100644 NetMonitorCliend/InIReader.cs diff --git a/NetMonitorCliend/InIReader.cs b/NetMonitorCliend/InIReader.cs new file mode 100644 index 0000000..c72accf --- /dev/null +++ b/NetMonitorCliend/InIReader.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Collections; +using System.Text.RegularExpressions; + +namespace NetMonitorCliend +{ + class InIReader + { + private StreamReader file; + private ArrayList cont; + public InIReader(string filename) + { + this.file = new StreamReader(filename); + FileSystemWatcher k = new FileSystemWatcher(filename); + k.Changed += new FileSystemEventHandler(this.readAgain); + loadFile(); + } + private void readAgain(object sender, EventArgs e) + { + this.file.BaseStream.Seek(0, SeekOrigin.Begin); + loadFile(); + } + private void loadFile() + { + string fline = ""; + while (fline != null) + { + fline = this.file.ReadLine(); + if (fline != null) + cont.Add(fline); + } + } + public ArrayList getSections() + { + ArrayList ret = new ArrayList(); + foreach (string sOutput in this.cont) + { + Match match = Regex.Match(sOutput, @"^\[[a-zA-Z0-9\-]\]\w*$", RegexOptions.IgnoreCase); + if (match.Success) + ret.Add(sOutput); + } + return ret; + } + + } +} diff --git a/NetMonitorCliend/NetMonitorCliend.csproj b/NetMonitorCliend/NetMonitorCliend.csproj index 1ec5c9e..af16470 100644 --- a/NetMonitorCliend/NetMonitorCliend.csproj +++ b/NetMonitorCliend/NetMonitorCliend.csproj @@ -55,6 +55,7 @@ Form1.cs + @@ -69,6 +70,7 @@ True Resources.resx + SettingsSingleFileGenerator Settings.Designer.cs