コードまたは Windows GUI を介して自分で変更するまで、システム (windows7) のデフォルトの dateTime 形式をプログラムで永続的に変更/更新/設定する必要があります。
Code Projectのこのようなソリューションをたくさん試しました
Console.Write(DateTime.Now + "");
RegistryKey rkey = Registry.CurrentUser.OpenSubKey(@"
Control Panel\International", true);
rkey.SetValue("sShortDate", "dd/MM/yyyy");
rkey.SetValue("sLongDate", "dd/MM/yyyy");
Console.Write(DateTime.Now + "");
最も近い評判の良い回答は、Set Default DateTime Format c#からの回答です。この解決策を試しましたが、役に立ちませんでした。システムの日時形式を変更しないため (タスクバーに表示)。このコードを含むアプリを再起動すると、このコードが実行される前に古い形式が再び取得されます。
using System;
using System.Globalization;
using System.Threading;
namespace test
{
public static class Program
{
public static void Main() {
Console.Write(DateTime.Now + "");// MessageBox.Show(DateTime.Now + "");
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "dd-MMM-yyyy";
culture.DateTimeFormat.LongTimePattern = "";
Thread.CurrentThread.CurrentCulture = culture;
Console.Write(DateTime.Now + "");// MessageBox.Show(DateTime.Now + "");
}
}
}