Tag Archives: c#
Get all system processes with C#

List all System running processes with the following code: public void GetAllProcesses() { foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses()) { try…

Get a list of opened windows C#

With the following method you can list all opened windows using C#. public void ListOpenedWindows() { IntPtr hwnd; foreach (System.Diagnostics.Process…

XML Serialization of C# Objects

To serialize a C# object to XML you need XmlSerializer class. 1. Create a Customer class for example [Serializable, XmlRoot("Customer"),…

Convert String to byte array in C#

Converting a byte array to string (unicode): byte[] b = Encoding.Unicode.GetBytes("unicode characters"); String s = Encoding.Unicode.GetString(b);byte[] b = Encoding.Unicode.GetBytes("unicode characters");…

Convert byte array to String in C#

Assuming that byte array contains data in Unicode format: byte[] data = ….; String data_s = Encoding.Unicode.GetString(data);byte[] data = ….;…

Connecting MS Access Database in C#

Let’s how we can connect to an MS Access database (accdb) in C#. String _database_path = "path/to/database/file"; String _conn_str =…

Hide console Window in C#

To hide console window in a C# console application your Program.cs file should be similar to this: namespace mynamespace {…

Show elapsed time on a Windows form in C#

We are going to use the Stopwatch class and a Timer. First of all we have to add two buttons,…

Banner grabbing with C#

TcpClient client = new TcpClient("http://mywebsite.com", 80); client.SendTimeout = 2000; client.ReceiveTimeout = 2000; NetworkStream ns = client.GetStream(); StreamWriter sw = new…

C# | Put time consuming operations in thread

Assuming that we have a time consuming operation in a function called TimeConsOperation. To execute it in a separated thread…

Previous Page · Next Page