I was playing around with localization when I encountered the following behaviuor: I set time & number format to "French (Canada)", and wrote:
DateTime.Now.ToString("dd/MM/yyyy")
I got:
12-12-2007
Instead of "/" I got "-".
I was looking around and couldn't find any documentation saying '/' is a special character in DateTime format string. Finally I used the following string which worked just fine:
DateTime.Now.ToString(@"dd\/MM\/yyyy")
Wednesday, December 12, 2007
Wednesday, December 5, 2007
How to list all installed sevice packs in C#
// Create WMI connection
ConnectionOptions options = new ConnectionOptions();
string machine = "127.0.0.1";
ManagementPath path = new ManagementPath(String.Format(
scope.Connect();
// Query
ObjectQuery query = new ObjectQuery(
ManagementObjectSearcher managerTemp =
//Get the results
ManagementObjectCollection returnCollection = managerTemp.Get();
foreach (ManagementObject managementObject in returnCollection)
{
ConnectionOptions options = new ConnectionOptions();
string machine = "127.0.0.1";
ManagementPath path = new ManagementPath(String.Format(
@"\\{0}\root\cimv2", machine));
ManagementScope scope = new ManagementScope(path, options);scope.Connect();
// Query
ObjectQuery query = new ObjectQuery(
"Select * from Win32_QuickFixEngineering");
ManagementObjectSearcher managerTemp =
new ManagementObjectSearcher(scope, query);
//Get the results
ManagementObjectCollection returnCollection = managerTemp.Get();
foreach (ManagementObject managementObject in returnCollection)
{
System.Console.WriteLine("*** New Item: ");
foreach (PropertyData propertyData in managementObject.Properties)
{
}foreach (PropertyData propertyData in managementObject.Properties)
{
System.Console.WriteLine(" {0} : {1}",
}propertyData.Name,
propertyData.Value);
propertyData.Value);
Subscribe to:
Posts (Atom)