Feed
Google+
Contact
XING
LinkedIn
Twitter
ICQ
meebo.com

C - why easy when it comes also complicated

by Roland Schumacher alias GENiALi 23. September 2009 -- 138 words  -- 1 mal gelesen

You never learn from. It should be.

I have the task to create a log file again. This should give the file a meaningful name. About "20090923_080355.txt". Such file names can now be built with the wildest methods.

Here an example from my early days (OK.) (This is not so long ago).

DateTime now = DateTime.Now;
string fileName = now.Year.ToString("0000") + now.Month.ToString("00") + now.Day.ToString("00") + "_" + now.Hour.ToString("00") + now.Second.ToString("00") + now.Millisecond.ToString("000") + ".txt";

Looks but quite workable. In any case, it works. But it is also easier?

It is a lot easier.

DateTime now = DateTime.Now;
string fileName = jetzt.ToString("yyyyMMdd_HHmmss_FFF") + ".txt";

Looks but already much more elegant.

To the info. "FFF" stands for the milliseconds. MSDN is to discover a lot more.

This gives but beautiful log file name. Can log file name be beautiful? ;-)

Liste mit Logdateinamen

kick it on dotnet-kicks.de

Tags:

Kommentare sind geschlossen

Statistik

Gesamte Posts: 1025
Dieses Jahr: 7
Diesen Monat: 1
Diese Woche: 0
Kommentare: 929
Total Bewertungen: 91
Ø Bewertung: 4,42
Meisten Kommentare
Google+ ... (28)
Beste Ø Bewertung
Tastaturlayout von Visual Stud ... (5)
Meiste Bewertungen
Windows 7 und die ersten Erfah ... (5)

Buttons

Stop Spam Harvesters, Join Project Honey Pot Benutzerprofil von GENiALi connection speed test network connection Bloggeramt.de Slug.ch Blog Verzeichnis und Blog Webkatalog Schumacher Roland Seitwert Valid XHTML 1.0 Transitional

writing