Danke Ralf für deine schnelle Antwort!
mein code sieht so aus:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84:
| using System; using System.IO; using System.Security.Permissions; using System.Drawing; using System.Windows.Forms; using System.Xml; using System.DirectoryServices; using System.DirectoryServices.ActiveDirectory; using System.Threading;
namespace Terminarbeiten {
public partial class quickmsg : Form {
public quickmsg() { InitializeComponent();
ListViewGroup on=new ListViewGroup(); on.Name="ON";on.Header="Online"; listView1.Groups.Add(on); ListViewGroup off=new ListViewGroup(); off.Name="off";off.Header="Offline"; listView1.Groups.Add(off); lv_refresh(); FileSystemWatcher fs = new FileSystemWatcher(); fs.Path=mainfrm.exepfad; fs.Filter="server.xml"; fs.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; fs.Changed += new FileSystemEventHandler(OnChanged); fs.EnableRaisingEvents = true; }
void lv_refresh() { listView1.BeginUpdate(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("server.xml"); XmlElement elmRoot = xmlDoc.DocumentElement; listView1.Items.Clear(); int userint; foreach (XmlNode element in elmRoot) {userint+=1; string lan=element.ChildNodes[0].InnerText; int onoff= Convert.ToInt32(element.ChildNodes[3].InnerText); ListViewItem itm = new ListViewItem(); itm.Group= listView1.Groups[onoff]; itm.Text=userint.ToString(); listView1.Items.Add(itm); } listView1.EndUpdate(); } void OnChanged(object sender, FileSystemEventArgs e) { lv_refresh(); }
} } |
XML-Daten
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE srv[ <!ATTLIST server id ID #IMPLIED> ]> <root> <server7> <name>User1</name> <port>10000</port> <ip>10.0.0.127</ip> <onoff>0</onoff> </server7> <server4> <name>User2</name> <port>10000</port> <ip>10.0.0.128</ip> <onoff>1</onoff> </server4> </root> |
habe Invoke, bevor ich den ersten Thread geschrieben hab, rausgenommen weil ich 8 stunden herumgesch.... habe und nix weiter ging. -.-
mfg Manfred