Ini Dateien leser hinzugefügt
This commit is contained in:
parent
93340aa3ea
commit
6f43c8a76b
50
NetMonitorCliend/InIReader.cs
Normal file
50
NetMonitorCliend/InIReader.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -55,6 +55,7 @@
|
|||||||
<Compile Include="Form1.Designer.cs">
|
<Compile Include="Form1.Designer.cs">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="InIReader.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="Form1.resx">
|
<EmbeddedResource Include="Form1.resx">
|
||||||
@ -69,6 +70,7 @@
|
|||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
Loading…
Reference in New Issue
Block a user