private void kbtnDisconnect_Click(object sender, EventArgs e) { UpdateStatus("Disconnecting drive..."); try { //unmap the drive _networkDrives.Force = kcbForceDisConnection.Checked; _networkDrives.LocalDrive = kcmbDriveLetter.Text; _networkDrives.UnMapDrive(); //update status UpdateStatus("Drive disconnection successful"); } catch (Exception err) { //report error UpdateStatus("Cannot disconnect drive! - " + err.Message); KryptonMessageBoxExtended.Show(this, "Cannot disconnect drive!\nError: " + err.Message); } _networkDrives = null; }
private void kbtnMapDrive_Click(object sender, EventArgs e) { UpdateStatus($"Mapping '{ ktxtShareAddress.Text }' to drive '{ kcmbDriveLetter.Text }'"); try { _networkDrives.Force = kcbForceDisConnection.Checked; _networkDrives.Persistent = kcbPersistantConnection.Checked; _networkDrives.LocalDrive = kcmbDriveLetter.Text; _networkDrives.PromptForCredentials = kcbPromptForCredentials.Checked; _networkDrives.ShareName = ktxtShareAddress.Text; _networkDrives.SaveCredentials = kcbSaveCredentials.Checked; if (ktxtUsername.Text == "" && ktxtPassword.Text == "") { _networkDrives.MapDrive(); } else if (ktxtUsername.Text == "") { _networkDrives.MapDrive(ktxtPassword.Text); } else { _networkDrives.MapDrive(ktxtUsername.Text, ktxtPassword.Text); } UpdateStatus("Drive mapping was successful!"); } catch (Exception exc) { UpdateStatus($"Cannot map drive! - { exc.Message }"); KryptonMessageBoxExtended.Show(this, "Cannot map drive!\nError: " + exc.Message); } _networkDrives = null; }