Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            DiscUtils.VolumeManager volMgr = new VolumeManager();
            volMgr.AddDisk(VirtualDisk.OpenDisk(textBox1.Text, FileAccess.Read));


            Stream partitionStream = null;

            if (!string.IsNullOrEmpty(VolumeId))
            {
                partitionStream = volMgr.GetVolume(VolumeId).Open();
            }
            else if (Partition >= 0)
            {
                partitionStream = volMgr.GetPhysicalVolumes()[Partition].Open();
            }
            else
            {
                partitionStream = volMgr.GetLogicalVolumes()[0].Open();
            }

            SparseStream cacheStream = SparseStream.FromStream(partitionStream, Ownership.None);

            cacheStream = new BlockCacheStream(cacheStream, Ownership.None);

            fs = new NtfsFileSystem(cacheStream);
            fs.NtfsOptions.HideHiddenFiles = false;
            fs.NtfsOptions.HideSystemFiles = false;
            fs.NtfsOptions.HideMetafiles   = false;

            ClusterMap clusterMap = null;

            try
            {
                clusterMap = fs.BuildClusterMap();
            }
            catch (IOException ex)
            {
                // DebugConsole.LogException(ex, "Trying to build a clustermap of " + textBox1.Text);
                MessageBox.Show(ex.Message, "Exception");
                // return;
            }
            // string[] files = null;


            // string[] sysfiles = fs.GetFileSystemEntries(@"\");
            // string[] files = fs.GetFiles(@"\", "*.*", SearchOption.AllDirectories);
            // fs.Dump(Console.Out, "");

            //QueuedBackgroundWorker.QueueWorkItem(QueuedBackgroundWorker.m_Queue, null,
            //    (args) => { return fs.GetFiles(@"\", "*.*", SearchOption.AllDirectories); },
            //    (args) => { if (args.Result != null && args.Result is string[]) ProcessFiles((string[])args.Result); }
            //);

            BitArray ba = new BitArray((int)fs.TotalClusters);

            for (int i = 0; i < fs.TotalClusters; i++)
            {
                if (clusterMap.ClusterToPaths(i).Length > 0)
                {
                    ba.Set(i, true);
                }
            }

            ClusterForm cf = new ClusterForm();

            cf.Icon = Icon;
            cf.Text = Text + " - Cluster Map";
            //cf.clusterBitmaps1.GradientStart = Color.WhiteSmoke;
            //cf.clusterBitmaps1.GradientEnd = Color.Black;
            //cf.clusterBitmaps1.GradientSteps = 8;
            cf.clusterBitmaps1.Clusters = ba;
            cf.Show();
        }