How to convert C# DateTime.Ticks into Unix timestamp

C# DateTime.Ticks ConverterWith the .NET frameworks DateTime functions you can do a lot of nice things. The handling turns out, in my opinion, very pleasant. The only requirement: You find yourself in a pure .NET environment. When other systems come into play, the trouble begins. But why is it that you can not compare DateTime.Ticks with the PHP mktime()-function?
If you request the “timestamp” from a DateTime-object (DateTime.Ticks), so you get back the number of ticks since 01.01.0001 00:00. A tick in turn is 100 nanoseconds long.
A Unix timestamp, as produced by mktime() for example, is to the contrary, the number of seconds since 01/01/1970. A direct comparison is not possible. So you have to convert between the both units at first. And how to do this, is what I want to show you today, based on a few […]

Simple XML serialization in C#

C# XML SerialisierungToday I want to show you how to perform a XML serialization in C#. Serialization itself, means that you convert an object to another, transportable form.
Using XML serialization, it is possible, for example, to store an object of a class in the form of an XML file and restore it later.
This can make sense if you if you want to transfer an object, for example, via HTTP or  restore an object to its state after closing and reopening an application.
For our example, I created the following class “Blog”:

public class Blog
{
public string User { get; set; }
public string Pass { get; set; }
public string Subdomain { get; set; }
public string BaseUrl { get; set; }
}

The method used to serialize is as follows:

public void […]

How to create articles on Blogspot with C#

Blogger C# API LogoToday I want to show you how to create a blog article on Blogger.com/Blogspot.com with C#. For this you need first of all the Google.GData.Client.dll, which you can find inside the Google .Net API package.
You can download the API package here from Google. (The file is called Google_Data_API_Setup_2.2.0.msi (Please note that the version number – 2.2.0 – over time may change of course.)
If the download is complete, install the package, open a new project in Visual Studio and add a reference to the Google.GData.Client.dll.
The .dll file can be found in the installation directory of the API package. (Click on the link “add a reference” above, if you need help embedding .dlls into a Visual Studio project.)
If you have included the DLL, you can start already. Blog posts (aka articles) can be created as follows:

private static int AddPost(string […]

WordPress2Doc – How to convert WordPress articles into Word and PDF documents

WordPress2Doc is a small program I developed, that enables you to convert your WordPress articles into Word (docx) documents. In addition to the Word format (.docx) the PDF format (.pdf) is available as a target format. For the conversion, the program makes use of the WordPress export XML file and can convert the items inside the export file in one or both of the aforementioned formats.
Tip: The download link for WordPress2Doc is at the end of this article! Who needs no further information, can now confidently scroll to the bottom of the article.
How to convert WordPress articles into pdf and docx files
To convert your WordPress articles into .docx or .pdf format, the relevant articles must be exported from WordPress at first. This can be done at WordPress’ backend. Therefore open the administration page of your blog and navigate to the “Tools-> Export” menu in the WordPress backend.

How to change the size of a textbox in C#

I admit, the title sounds almost trivial. But on the second sight, it is not so easy to change the size of a TextBox control in C#, because a TextBox does not have the AutoSize property. For other controls you can set the AutoSize property to false and then change the height (height-property). For the TextBox control this is unfortunately not the case.
Nevertheless you can set the height of a TextBox by using a small workaround. The trick is as follows:

textBoxTest.Multiline = true;
textBoxTest.MinimumSize = new Size(150, 24);
textBoxTest.Size = new Size(150, 24);
textBoxTest.Multiline = false;

First you have to set the multiline property to true. Then you can adjust, according to your mood, the minimum-size and the size property to change the size of the TextBox. When you’re done, you set the Multiline property back to false. The TextBox maintains the set size just yet. It’s that simple
Who still wonders, why you should […]