You can stick a fork in RIM -- they're done. Whenever a company tries to soothe investors and customers by boasting about their cash reserves, it's only a matter of time until they crash and burn. Back in the mid-nineties, I attended a company rally during which Mary Burnside stated that Novell was doing just fine because they had a billion dollars in the bank. Shortly after that, there was an executive exodus (including Burnside) and the cash reserves disappeared very quickly. Competing products from Google, Apple, and Microsoft were major factors in RIMs decline, but ultimately, horrible executive decisions did them in -- just like Novell.
ChunkyStool
Posts
-
RIMs CEOs have stepped down -
Do you not understand booleans?I'm with you on this one! Sometimes verbosity improves readability, but there are many cases where it's just dumb. The first example is terrible:
bool is_queue_empty(void)
{
if (queue_length==0)
{
return true;
}
else
{
return false;
}
}More code & multiple exit points -- for zero benefit???!!! X| This would be better:
bool is_queue_empty(void)
{
return queue_length == 0;
}:)
-
Queue through all files in a directory (and subdirectories).No biggie. Recursion would be ideal for this scenario. ;)
-
Queue through all files in a directory (and subdirectories).Why queue the directories? GetDirectories() returns an array, so putting them in a collection seems redundant. Some error handling wouldn't hurt either. If an exception is thrown, the entire operation fails.
-
the result of DefragAnalysis method in c#Yeah, there's not much C# sample code for WMI anywhere -- including MSDN. That really sucks because WMI isn't very intuitive. I tested WMI for 8+ years and still struggle with some features... :wtf: The DefragAnalysis method returns 3 things: return code (which you got), a bool that indicates whether or not a defrag is recommended, and an instance of Win32_DefragAnalysis. The bool & instance get "wrapped" in an object array. All you have to do is tell the method where to put the objects. Think of the "outParams" array as a mailbox with 2 slots. Null values are fine. Here's some sample code. (Note, it isn't necessary to specify scope for Vista or Server 2008 because the defaults are local machine & “root\cimv2”. I only included it for backward compatibility.)
using System;
using System.Management;namespace DefragAnalysis
{
class Program
{
static void Main(string[] args)
{
try
{
string scope = @"\\.\root\cimv2";
string query = @"SELECT * FROM Win32_Volume WHERE Name = 'C:\\'";
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
object[] outputArgs = new object[2];foreach (ManagementObject volume in searcher.Get()) { UInt32 result = (UInt32)volume.InvokeMethod("DefragAnalysis", outputArgs); if (result == 0) { Console.WriteLine("Defrag Needed = {0}\\n", outputArgs\[0\]); ManagementBaseObject defragAnalysis = outputArgs\[1\] as ManagementBaseObject; if (null != defragAnalysis) { foreach (PropertyData property in defragAnalysis.Properties) { Console.WriteLine("{0} = {1}", property.Name, property.Value); } } } else { Console.WriteLine("Method return code = 0x{0:X}", result); } } } catch (Exception ex) { Console.WriteLine("Something bad happened.\\n" + ex); } finally { Console.WriteLine("\\npress any key to exit..."); Console.ReadKey(); } }