Exemplo n.º 1
0
        /// <summary>
        /// Initializes the partitions for all block devices.
        /// </summary>
        protected virtual void InitializePartitions()
        {
            Console.WriteLine("Loading partitions...");
            foreach (var t in BlockDevice.Devices)
            {
                if (t is Partition partition)
                {
                    mPartitions.Add(partition);
                }
            }

            if (mPartitions.Count > 0)
            {
                tablePrinter.WriteHeaders("Partition #", "Block Size", "Block Count", "Size");
                for (int i = 0; i < mPartitions.Count; i++)
                {
                    tablePrinter.WriteRow((i + 1).ToString(), mPartitions[i].BlockSize + " bytes", mPartitions[i].BlockCount.ToString(), mPartitions[i].BlockCount * mPartitions[i].BlockSize / 1024 / 1024 + " MB");
                }
            }
            else
            {
                Console.WriteLine("No partitions found!");
            }
        }