예제 #1
0
        private void btnMount_Click(object sender, EventArgs e)
        {
            VssSnapshotProperties snapshot = GetVssSnapshotFromTime(DateTime.Parse(lvRestorePoints.Items[lvRestorePoints.SelectedIndices[0]].Text));

            if (snapshot != null)
            {
                string[] path       = snapshot.SnapshotDeviceObject.Split('\\');
                string   mountPoint = systemDrive + path[path.Length - 1];

                // Create the hardlink
                bool symResult = VolumeNativeMethods.CreateSymbolicLink(mountPoint, snapshot.SnapshotDeviceObject + @"\", 1);

                if (symResult)
                {
                    // Start explorer at the mount point
                    ProcessStartInfo explorer = new System.Diagnostics.ProcessStartInfo();
                    explorer.FileName  = "explorer.exe";
                    explorer.Arguments = mountPoint;
                    Process.Start(explorer);

                    btnMount.Enabled   = false;
                    btnUnmount.Enabled = true;

                    tsmiMount.Enabled   = false;
                    tsmiUnmount.Enabled = true;
                }
            }
        }
예제 #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            // Get selected restore point
            SystemRestoreItem selectedSystemRestoreItem = null;
            string            time = lvRestorePoints.Items[lvRestorePoints.SelectedIndices[0]].Text;
            DateTime          selectedCreationTime = DateTime.Parse(time);

            foreach (SystemRestoreItem sri in systemRestorePoints)
            {
                if (sri.CreationTime.ToLocalTime().CompareTo(selectedCreationTime) == 0)
                {
                    selectedSystemRestoreItem = sri;
                    break;
                }
            }

            if (selectedSystemRestoreItem.SequenceNumber > 0)
            {
                // Need to display are you sure dialog!
                string           prompt = "Are you sure you want to remove system restore point?";
                TaskDialogResult tdr    = TaskDialog.Show(this, selectedSystemRestoreItem.CreationTime.ToString() + "\n" + selectedSystemRestoreItem.Description, prompt, this.Text, TaskDialogButtons.Yes | TaskDialogButtons.No, TaskDialogIcon.Warning);

                // If the user is sure
                if (tdr == TaskDialogResult.Yes)
                {
                    // Remove the restore point
                    uint result = VolumeNativeMethods.SRRemoveRestorePoint(selectedSystemRestoreItem.SequenceNumber);

                    // If success
                    if (result == 0)
                    {
                        // Update internal data on system restore points and shadow storage
                        systemRestorePoints = new SystemRestorePoints();
                        shadowStorage       = new ShadowStorage();

                        lblDiskSpace.Text = shadowStorage.UsedSpaceString;
                        UpdateListView(sender, e);

                        // Only show chkOlder if there are older restore points
                        int olderCount = 0;

                        foreach (SystemRestoreItem sri in systemRestorePoints)
                        {
                            if (sri.CreationTime.ToLocalTime().CompareTo(DateTime.Now.Subtract(TimeSpan.FromDays(5))) < 0)
                            {
                                olderCount++;
                            }
                        }

                        if (olderCount > 0)
                        {
                            chkHideNewest.Visible = true;
                        }
                        else
                        {
                            chkHideNewest.Visible = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error deleting restore point");
                    }
                }
            }
        }