diff --git a/Server/Forms/FrmFileManager.cs b/Server/Forms/FrmFileManager.cs index 587cf61a..c14c50a0 100644 --- a/Server/Forms/FrmFileManager.cs +++ b/Server/Forms/FrmFileManager.cs @@ -60,14 +60,14 @@ private void lstDirectory_DoubleClick(object sender, EventArgs e) { if (lstDirectory.SelectedItems.Count != 0) { - if (lstDirectory.SelectedItems[0].Tag.ToString() == "dir" && lstDirectory.SelectedItems[0].SubItems[0].Text == "..") + if (lstDirectory.SelectedItems[0].Tag.ToString() == "dir" && _connectClient.Value != null) { - if (_connectClient.Value != null) + if (lstDirectory.SelectedItems[0].SubItems[0].Text == "..") { - if (!_currentDir.EndsWith(@"\")) - _currentDir = _currentDir + @"\"; - - _currentDir = _currentDir.Remove(_currentDir.Length - 1); + if (_currentDir.EndsWith(@"\")) + { + _currentDir = _currentDir.Remove(_currentDir.Length - 1); + } if (_currentDir.Length > 2) _currentDir = _currentDir.Remove(_currentDir.LastIndexOf(@"\")); @@ -78,17 +78,14 @@ private void lstDirectory_DoubleClick(object sender, EventArgs e) new Core.Packets.ServerPackets.Directory(_currentDir).Execute(_connectClient); _connectClient.Value.LastDirectorySeen = false; } - } - else if (lstDirectory.SelectedItems[0].Tag.ToString() == "dir") - { - if (_connectClient.Value != null) + else { if (_connectClient.Value.LastDirectorySeen) { if (_currentDir.EndsWith(@"\")) - _currentDir = _currentDir + lstDirectory.SelectedItems[0].SubItems[0].Text; + _currentDir += lstDirectory.SelectedItems[0].SubItems[0].Text; else - _currentDir = _currentDir + @"\" + lstDirectory.SelectedItems[0].SubItems[0].Text; + _currentDir += @"\" + lstDirectory.SelectedItems[0].SubItems[0].Text; new Core.Packets.ServerPackets.Directory(_currentDir).Execute(_connectClient); _connectClient.Value.LastDirectorySeen = false; diff --git a/Server/Forms/FrmSettings.cs b/Server/Forms/FrmSettings.cs index a14c98b6..0693c010 100644 --- a/Server/Forms/FrmSettings.cs +++ b/Server/Forms/FrmSettings.cs @@ -36,20 +36,32 @@ private void btnListen_Click(object sender, EventArgs e) { if (btnListen.Text == "Start listening" && !_listenServer.Listening) { - if (chkUseUpnp.Checked) - Core.Helper.UPnP.ForwardPort(ushort.Parse(ncPort.Value.ToString())); + try + { + if (chkUseUpnp.Checked) + Core.Helper.UPnP.ForwardPort(ushort.Parse(ncPort.Value.ToString())); + _listenServer.Listen(ushort.Parse(ncPort.Value.ToString())); + } + finally + { - _listenServer.Listen(ushort.Parse(ncPort.Value.ToString())); - btnListen.Text = "Stop listening"; - ncPort.Enabled = false; - txtPassword.Enabled = false; + btnListen.Text = "Stop listening"; + ncPort.Enabled = false; + txtPassword.Enabled = false; + } } else if (btnListen.Text == "Stop listening" && _listenServer.Listening) { - _listenServer.Disconnect(); - btnListen.Text = "Start listening"; - ncPort.Enabled = true; - txtPassword.Enabled = true; + try + { + _listenServer.Disconnect(); + } + finally + { + btnListen.Text = "Start listening"; + ncPort.Enabled = true; + txtPassword.Enabled = true; + } } }