StreamWriter

string _FileText = "some text"; using (System.IO.StreamWriter _StreamWriter = new System.IO.StreamWriter("PathFile")) { _StreamWriter.Write(_FileText); _StreamWriter.Flush(); } using (System.IO.StreamWriter _StreamWriter = new System.IO.StreamWriter("PathFile")) { foreach (System.IO.DirectoryInfo _DirectoryInfo in new DirectoryInfo(@"c:\").GetDirectories()) { _StreamWriter.WriteLine(_DirectoryInfo.Name); } } MSDN Artikel

Von |2015-06-14T13:44:13+02:00Juni 14th, 2015|0 Kommentare

StreamReader

string _FileText; using (System.IO.StreamReader _StreamReader = new System.IO.StreamReader("PathFile")) { _FileText = _StreamReader.ReadToEnd(); } string _TextLine; using (System.IO.StreamReader _StreamReader = new System.IO.StreamReader("PathFile")) { while ((_TextLine = _StreamReader.ReadLine()) != null) { Console.WriteLine(_TextLine); } } MSDN Artikel

Von |2015-06-14T13:35:51+02:00Juni 14th, 2015|0 Kommentare

sgen

Der XML Serializer Generator erstellt eine XML-Serialisierungsassembly für die Typen in einer bestimmten Assembly, um die Startleistung von XmlSerializer beim Serialisieren oder Deserialisieren von Objekten der angegebenen Typen zu erhöhen. "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sgen.exe" force xy.dll MSDN Artikel

Von |2015-06-14T13:29:08+02:00Juni 14th, 2015|0 Kommentare

Lamda Expressions

this.button1.Click += (_sender, _e) => { System.Windows.Forms.MessageBox.Show(_sender.ToString()); }; delegate int del(int i); static void Main(string[] args) { del myDelegate = x => x * x; int j = myDelegate(5); //j = 25 } using System.Linq.Expressions; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Expression<del> myET = x => x * x; [...]

Von |2015-06-13T22:52:43+02:00Juni 12th, 2015|0 Kommentare

DataView (DataSet)

System.Data.DataView _DataView = new System.Data.DataView(_DataSet.Tables[0]); _DataView.Sort = "Order ASC"; foreach (System.Data.DataRowView _DataRowView in _DataView) { switch (_DataRowView[1].ToString()) { } } //DISTINCT System.Data.DataView _DataView = new System.Data.DataView(_DataSet.Tables["TableName"]); System.Data.DataTable _DataTable = _DataView.ToTable(true, "Column"); foreach (System.Data.DataRow _DataRow in _DataTable.Rows) { } // End: foreach //SUM object _sumObject; _sumObject = table.Compute("Sum(Total)", "EmpID = 5");

Von |2015-06-13T22:52:24+02:00Juni 12th, 2015|0 Kommentare

DataSet

System.Data.DataSet _DataSet = new System.Data.DataSet("DataSetName"); _DataSet.Tables.Add("Tablename"); _DataSet.Tables["Tablename"].Merge(SomeOtherDataSet("SELECT * FROM table", "Tablename").Tables[0]); _DataSet.Relations.Add(_DataSet.Tables["Parent"].Columns["ID"], _DataSet.Tables["Child"].Columns["FK_Parent"]) _DataSet.Relations.Add(_DataSet.Tables["Parent"].Columns["ID"], _DataSet.Tables["Child"].Columns["FK_Parent"]).Nested = true; _DataSet.WriteXml(@"C:\Temp\TestXML.xml"); for (int i = 0; i <= _DataSet.Tables["Tablename"].Rows.Count - 1; i += 1) { if (_DataSet.Tables["Tablename"].Rows[i]["ID"].ToString() != "") { string _Text = _DataSet.Tables["Tablename"].Rows[i]["Text"].ToString(); } } foreach (System.Data.DataTable _DataTable in _DataSet.Tables) { foreach (System.Data.DataRow _DataRow in _DataTable.Rows) [...]

Von |2015-06-13T22:52:02+02:00Juni 10th, 2015|0 Kommentare

Windows gesperrt / entsperrt überprüfen

Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch); private void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e) { if (e.Reason == Microsoft.Win32.SessionSwitchReason.SessionLock) { DoSomething(); } else if (e.Reason == Microsoft.Win32.SessionSwitchReason.SessionUnlock) { DoSomethingElse(); } }

Von |2015-06-13T22:52:53+02:00Juni 10th, 2015|0 Kommentare

DataTable

System.Data.DataSet _DataSet = new System.Data.DataSet("MyDataSet"); System.Data.DataRow _DataRow; System.Data.DataTable _DataTable01 = new System.Data.DataTable(); _DataTable01.Columns.Add(new System.Data.DataColumn("Col_String", Type.GetType("System.String"))); // typeof("string") _DataTable01.Columns.Add(new System.Data.DataColumn("Col_DateTime", Type.GetType("System.DateTime"))); _DataTable01.Columns.Add(new System.Data.DataColumn("Col_Int32", Type.GetType("System.Int32"))); _DataTable01.Columns.Add(new System.Data.DataColumn("Col_Decimal", Type.GetType("System.Decimal"))); _DataRow = _DataTable01.NewRow(); _DataRow["Col_String"] = "Col_String_01"; _DataRow["Col_Int32"] = 1; _DataTable01.Rows.Add(_DataRow); System.Data.DataTable _DataTable02 = new System.Data.DataTable(); _DataTable02.Columns.Add(new System.Data.DataColumn("Col_String", Type.GetType("System.String"))); _DataTable02.Columns.Add(new System.Data.DataColumn("Col_DateTime", Type.GetType("System.DateTime"))); _DataTable02.Columns.Add(new System.Data.DataColumn("Col_Int32", Type.GetType("System.Int32"))); _DataTable02.Columns.Add(new System.Data.DataColumn("Col_Decimal", Type.GetType("System.Decimal"))); _DataRow [...]

Von |2015-06-13T22:52:14+02:00Juni 5th, 2015|0 Kommentare