Self deletable application in C# in one executable

If you use Process.Start you can pass in the Del parameter and the path to the application you wish to delete. ProcessStartInfo Info=new ProcessStartInfo(); Info.Arguments=”/C choice /C Y /N /D Y /T 3 & Del “+ Application.ExecutablePath; Info.WindowStyle=ProcessWindowStyle.Hidden; Info.CreateNoWindow=true; Info.FileName=”cmd.exe”; Process.Start(Info); Code snippet taken from this article

.net Core Quartz Dependency Injection

You can use the Quartz.Spi.IJobFactory interface and implement it. The Quartz documentations states: When a trigger fires, the Job it is associated to is instantiated via the JobFactory configured on the Scheduler. The default JobFactory simply activates a new instance of the job class. You may want to create your own implementation of JobFactory to … Read more

.NET: Get all Outlook calendar items

I’ve studied the docs and this is my result: I’ve put a time limit of one month hard-coded, but this is just an example. public void GetAllCalendarItems() { Microsoft.Office.Interop.Outlook.Application oApp = null; Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null; oApp = new Microsoft.Office.Interop.Outlook.Application(); mapiNamespace = oApp.GetNamespace(“MAPI”); ; CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); … Read more

Drag and drop a DLL to the GAC (“assembly”) in windows server 2008 .net 4.0

In .net 4.0 Microsoft removed the ability to add DLLs to the Assembly simply by dragging and dropping. Instead you need to use gacutil.exe, or create an installer to do it. Microsoft actually doesn’t recommend using gacutil, but I went that route anyway. To use gacutil on a development machine go to: Start -> programs … Read more

Sort a wpf datagrid programmatically

voo’s solution was not working for me, ItemsSource was null, most likely because it was not directly set, but bound. All other solutions I found here at StackOverflow were dealing with sorting the Model only, but the DataGrid header was not reflecting to the sort. Here’s a proper solution based on the incomplete script here: … Read more

Upload CSV file to SQL server

1st off, You don’t need programming stuff. You can directly upload CSV files into SQL Database with SQL management tools. However, if you really need do it through programming, Just read below. Personally, I think this approach is the most efficient and easiest way to do through programming. In general, you can achieve it in … Read more

What causes “extension methods cannot be dynamically dispatched” here?

So, can somebody please help me understand why leveraging the same overload inside of those other methods is failing with that error? Precisely because you’re using a dynamic value (param) as one of the arguments. That means it will use dynamic dispatch… but dynamic dispatch isn’t supported for extension methods. The solution is simple though: … Read more