Skip to main content

WPF – OpenFileDialog

openfiledialog

This is a simple example to have an OpenFileDialog (a premade view done by Windows to select a file to open) with WPF, filtering on XLSX file: In this case the InitialDirectory will always exist because it is the Desktop of the current user. But you have to know that if the targeted InitialDirectory doesn’t […]

C# – AutoMapper Configuration Tutorial

automapper logo

What is AutoMapper? AutoMapper is a C# library which allows to do the mapping automatically between two similar objects. Typically really useful to map for example a domain model to a DTO (Data Transfer Object) or from a UI model to other layers of your code. Why should you use AutoMapper? Of course you always […]

C# – How to use Serilog

serilog-logo

There are many log libraries on NuGet, but I would say the 3 most known ones are NLog, Log4Net and Serilog. This article will focus on Serilog with a simple example of how to start with it. Why should you use Serilog? Serilog is a powerful library allowing you to create logs for your application […]

C# – Read Settings from the AppSettings.json

appsettings json

You might be used to the good old web.config or app.config file. But if you upgrade your solution to something a bit more modern like .Net 5, then it will be transformed to appsettings.json. Here are some tips about how to use the appsettings.json. The app.config file was stored as an XML file. So you […]

C# – Upgrade Your Solution To .Net

upgrade .Net Framework to .Net

This article will talk about how you can easily upgrade your .Net Framework solution to .Net 5 (6, Core, Standard). Microsoft released a simple dotnet script to do this painful task for you. Currently the tool supports the following .NET Framework app types: .NET Framework Windows Forms apps .NET Framework WPF apps .NET Framework ASP.NET […]

WPF – ContentControl and TemplateSelector

Content_selection

Here is a simple example about the ContentControl and the TemplateSelector. This is really useful when you have a single model that can be represented on the UI in different ways depending on an enum for example. This will be the final result in the UI while using the same model: Let’s start with our […]

C# – BDD Tests with xBehave and xUnit

given-when-then

In this post we will see the basics of BDD with xUnit and xBehave. But not only! If you don’t know what are: BDD, Gherkin, integration tests, Cucumber, SpecFlow, xUnit or xBehave, read the following sections. Otherwise, just skip straight to a simple example of an integration test with C# based on xBehave and xUnit. […]

C# Multiply all elements from a list

mulitply aggregate

Here is a really short and simple example of how multiply all elements from a list with C#. The bad way and the good way. The bad way to multiply items from a list with C# There is actually nothing bad about it. It is just not sexy and doesn’t use LINQ. But to be […]

Unzip file using C#

unzip

Extracting the content of a ZIP file is really common. And here is a simple example of how to do it with C# using ZipFile and SharpZipLib. If you are using .Net Framework 4.6.0 or up you can use System.IO.Compression.ZipFile from Microsoft. But if you are lower than 4.6 then you can use SharpZipLib from […]

C# – FTP With ComponentPro

FTP

ComponentPro is a professional suite of libraries for FTP, sFTP and document manipulations (Word, Excel, PDF, …). Here is a simple example of how to use it with (s)FTP.