Tag Archives: csharp

How to display a progressbar in taskbar in C#

You might have noticed that programs display a progress bar in the taskbar a lot of times. This allows users to see the progression of the task even if the application is minimized by simply looking at the taskbar. Today I will be showing you a way to achieve that functionality so you can use it in your projects.

Taskbar progress bar

First you will need to download Windows API Code Pack for Microsoft .NET Framework. Extract the contents of the file and search for Microsoft.WindowsAPICodePack.Shell.dll which is located under the binaries folder.

Add Microsoft.WindowsAPICodePack.Shell.dll as a reference to your project. This will allow you to use the namespaces which are required in order to display the progress bar.

The code below is an example on how you can implement the feature.

How to get your IP in C#

There are two ways of getting your IP address in C#. One of them is by using the methods provided by the .NET framework and the other one by using a third party api.

What is the difference you might ask. The answer is fairly simple. There are two kinds of IP’s, internal IP’s and external IP’s. Sadly the .NET framework methods are not able to retrieve the external IP if the computer is not directly connected to the internet (no router or any other similar devices). Since this limitation exists there is only one option if you wish to get the external IP, and this is by using an online service.

I’ve constructed two methods below. One uses only the .NET framework methods but is not 100% accurate when trying to retrieve the external IP (requires the system to be directly connected to the internet). The second method uses an online service which should have fairly accurate results as long as the service is online and the computer is not behind a proxy.

Method 1
LINQ approach

Non-LINQ approach (for .NET framework versions before 3.5)

Method 2

RC4 cypher in C#

Main method:

Usage:

ROT-13 cypher in C#

ROT-13 is a letter substitution cypher that replaces a letter with the letter 13 letters after it in the alphabet. ROT-13 is an example of the Caesar cypher with the difference that Caesar cypher allows you to specify the number of letters to shift.

Main method:

Usage:

Atom-128 algorithm in C#

Encode method:

Decode method:

Usage: