Tag Archives: progressbar
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.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | if (Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager.IsPlatformSupported) { int maxProgressbarValue = 100; var taskbarInstance = Microsoft.WindowsAPICodePack.Taskbar.TaskbarManager.Instance; taskbarInstance.SetProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.Normal); for (int i = 0; i < maxProgressbarValue; i++) { taskbarInstance.SetProgressValue(i, maxProgressbarValue); Thread.Sleep(50); } taskbarInstance.SetProgressState(Microsoft.WindowsAPICodePack.Taskbar.TaskbarProgressBarState.NoProgress); } else { // Platform does not support the feature. } |
How to download a file in C# (progressbar and download speed)
This is a simple snippet that will allow you to download a file from the internet in C# while being able to display the download percentage, download speed and the amount of total data received while downloading.
This is the example form of what to expect when you have the code in place:
Posted in C#.
Tagged C#, csharp, download file, progressbar, webclient download speed, winforms