Esempio n. 1
0
        private static void DriveInfoClassDemo()
        {
            DriveInfoClass dic = new DriveInfoClass();

            dic.GetDriveInfoDetails();

            DriveInfoClass.ListDirectories(new System.IO.DirectoryInfo(@"C:\Program Files"), "*a*", 5, 0);

            try
            {
                DriveInfoClass.DirectoryMove("D:\\Accenture", "D:\\Hello World\\TestMove");
                DriveInfoClass.GetDirectoryUsingFile();
                DriveInfoClass.DeleteFile();
                DriveInfoClass.CopyFiles();
                DriveInfoClass.GetPathDetails();

                DriveInfoClass.FileCreateTextDemo();

                DriveInfoClass.WebRequestDemo();

                string data;

                //Task<data> = DriveInfoClass.CreateandWriteAsyncToFile();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Esempio n. 2
0
        private void cmbFormat_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Make sure drive letter is formatted
            formatDriveLetter = cmbFormat.SelectedItem.ToString().Substring(0, 2); // C:

            //Load the info from the selected drive
            txtVolumeLabel.Text = DriveInfoClass.GetDriveLabel(formatDriveLetter);                        // New Volume
            txtDriveSize.Text   = DriveInfoClass.GetDriveSize(formatDriveLetter).ToString("0.0") + " GB"; // 32.0 GB
        }
Esempio n. 3
0
        public bool VerifyFormatData(string driveLetter)
        {
            //Check that the drive selected is not the OS drive
            if (DriveInfoClass.ISOSDrive(driveLetter))
            {
                MessageBox.Show("You cannot format an OS drive!",
                                "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            else
            {
                //Make sure that the user knows the repercussions.
                DialogResult result = MessageBox.Show("WARNING: Formatting will erase ALL data on this disk." +
                                                      " To format the disk, click OK. To quit, click CANCEL",
                                                      "Format " + DriveInfoClass.GetDriveLabel(driveLetter) + " " + driveLetter,
                                                      MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);

                if (result == DialogResult.OK)
                {
                    volumeLabel = txtVolumeLabel.Text;
                    fileSystem  = cmbFileSystem.SelectedItem.ToString();
                    quickFormat = chkQuickFormat.Checked;
                    compression = chkCompression.Checked;

                    //Make sure drive letter is formatted as ex: "C:"
                    driveLetter = cmbFormat.SelectedItem.ToString();
                    driveLetter = driveLetter.Substring(0, 2);

                    //Get Allocation size
                    //Get the number from the text on the combo box
                    string temp = cmbAllocationSize.SelectedItem.ToString();
                    int    pos  = temp.IndexOf(" ");
                    temp = temp.Substring(0, pos);

                    //Check to see if the selected item is above the 4th item
                    if (cmbAllocationSize.SelectedIndex > 4)
                    {
                        clusterSize = Convert.ToInt32(temp) * 1000;
                    }
                    else
                    {
                        clusterSize = Convert.ToInt32(temp);
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Esempio n. 4
0
        public void RefreshDrives()
        {
            cmbOverview.SelectedIndexChanged -= new EventHandler(cmbOverview_SelectedIndexChanged);
            cmbOverview.Items.Clear();
            cmbFormat.Items.Clear();

            cmbOverview.Items.AddRange(DriveInfoClass.GetDrives().ToArray());
            cmbFormat.Items.AddRange(DriveInfoClass.GetDrives().ToArray());
            cmbFormat.SelectedIndex           = 0;
            cmbOverview.SelectedIndex         = 0;
            cmbOverview.SelectedIndexChanged += new EventHandler(cmbOverview_SelectedIndexChanged);
        }
Esempio n. 5
0
 public void LoadDriveInfo()
 {
     rtbDriveInfo.Text = DriveInfoClass.GetDriveInformation(cmbOverview.SelectedItem.ToString());
 }