How to retrieve default browsers path in C#

csharp_standard_browserBelow it will be about how to find the path to the default browser on Windows systems with help of C#. This makes sense, if you want to open a file using Process.Start () in the default browser.
Although one might assume that every Windows user has installed Internet Explorer and you should therefore simply use this to view files, but it does not necessarily increase the confidence of the user into the own application. So at least I, as a user, would be annoyed of my program, if this would always launch Internet Explorer instead of Firefox, which I have set as the default browser.
Now there are two ways to open the default browser in C #. Both have their advantages and disadvantages.
Option 1 – Process.Start() with an URL
The easiest […]

How to create video files in C# (from single images)

create videos in csharpToday there is again a bit of C# code. I’m writing about how you can create video files in C # from individual images or bitmaps. Using the AForge library, which I have used in the already in the C# webcam tutorial, this is going to be relatively simple.
Preparations
For the following tutorial you need the AForge.Video.FFMPEG.dll library and its FFMPEG libraries. Both can be found by clicking the below link. On the downloadpage you have to select that .zip-file, which contains “(libs only)” in it’s filename.

AForge Libs Download

Now open your Visual Studio or an alternative program, that you want to use to write your program. (For the following tutorial I’m using Visual Studio.)
Create a project
Next you create a new project, I decided on a WinForms project, and wait until the […]

Performance test: rotate images in C# – Bitmap.RotateFlip vs.Graphics-Object

During my search for a function to rotate images in C#, I came across the following post on dotnet-snippets.de: rotate images with C #.
Besides the method presented in the article there were 2 other approaches presented in the comments and so the question was: which method is the fastest of them.
Since this also awakened my interest, I wrote a small test application which checks every of those functions for their performance.
After a few test runs, it became clear that the original solution from the above mentioned post was not suitable because it created a new bitmap every run, what eats tons of memory. Thus, the following function has been excluded from the tests.

public Bitmap rotateImage(Bitmap bitmap, float angle)
{
Bitmap returnBitmap = new Bitmap(bitmap.Width, bitmap.Height);
Graphics graphics = Graphics.FromImage(returnBitmap);
graphics.TranslateTransform((float)bitmap.Width / 2, (float)bitmap.Height / 2);
[…]

3 things you should know to speed up HttpWebRequest

HttpWebRequest LogoThose who work with the. NET framework and occasionally used the HttpWebRequest class, may have stumbled about the phenomenon that it seems to be quite slow in some cases. Especially if you use HttpWebRequest in combination with threading to get responses as quick as possible, the HttpWebRequest class quickly becomes a party pooper.
Initially you might assume that the problems rely on the Internet connection, but at least after a speed comparison with wget or curl, you should recognize that the “problem” must be at the. NET implementation.
No products found.In the following article I will focus on three points that can help you, to speed up the HttpWebRequests class.

1. Increase DefaultConnectionLimit
All instances of the HttpWebRequest class are using some properties of the ServicePointManager. One of these porperties of the ServicePointManager is the “DefaultConnectionLimit”. By default, this […]

How to solve representation/encoding errors in C# Winforms applications

I know the title of this post hurts, but I wasn’t able to describe the problem with fewer words. But let us get to the point. As part of the development of my cloud downloader I encountered (among much others) the following problem. Korean characters were displayed as blank boxes, even though they were shown in the source code editor correctly. Those of you, who wonder now,  from where you can get the Korean characters on your keyboard, should just stop by Google Translate. (The screenshot below illustrates the problem once again. Please click to enlarge the image.)
Koreanische Zeichen falsche Darstellung
On the Internet I found only very few solutions. And almost all were, in my opinion, rather suboptimal. In most cases the following solution was proposed:
It is recommended that you call the SetCompatibleTextRenderingDefault() method with the parameter true. In […]