怎样知道一个盘的大小,没有使用的空间有多大?,比如我想知道c盘有多大,目前有多少闲置空间

解决方案 »

  1.   

    using System;
    using System.IO;class Test 
    {
        public static void Main() 
        {
            // Specify the directories you want to manipulate.
            DirectoryInfo di = new DirectoryInfo(@"c:\MyDir");
            try 
            {
                // Determine whether the directory exists.
                if (di.Exists) 
                {
                    // Indicate that the directory already exists.
                    Console.WriteLine("That path exists already.");
                    return;
                }            // Try to create the directory.
                di.Create();
                Console.WriteLine("The directory was created successfully.");            // Delete the directory.
                di.Delete();
                Console.WriteLine("The directory was deleted successfully.");        } 
            catch (Exception e) 
            {
                Console.WriteLine("The process failed: {0}", e.ToString());
            } 
            finally {}
        }
    }
    [C++] 
    #using <mscorlib.dll>using namespace System;
    using namespace System::IO;void main() {
        // Specify the directories you want to manipulate.
        DirectoryInfo* di = new DirectoryInfo(S"c:\\MyDir");
        try {
            // Determine whether the directory exists.
            if (di->Exists) {
                // Indicate that the directory already exists.
                Console::WriteLine(S"That path exists already.");
                return;
            }        // Try to create the directory.
            di->Create();
            Console::WriteLine(S"The directory was created successfully.");        // Delete the directory.
            di->Delete();
            Console::WriteLine(S"The directory was deleted successfully.");
        } catch (Exception* e) {
            Console::WriteLine(S"The process failed: {0}", e);
        } 
    }