private void ConnectBtn_Click(object sender, EventArgs e) { myFTP = new MyFTP(); myFTP.Server = ServerBox.Text.Trim(); if (myFTP.Server.Length == 0) { ServerWarning.Visible = true; ServerBox.Focus(); return; } ServerWarning.Visible = false; myFTP.UserName = UserNameBox.Text.Trim(); if (myFTP.UserName.Length == 0) { UserWarning.Visible = true; UserNameBox.Focus(); return; } UserWarning.Visible = false; myFTP.Password = PwdBox.Text.Trim(); try { myFTP.Port = int.Parse(PortBox.Text); }catch { PortWarning.Visible = true; PortBoxLabel.Focus(); return; } PortWarning.Visible = false; RemoteTree.Nodes.Clear(); AddLog($"正在尝试连接 {myFTP.Server}:{myFTP.Port}......"); try { myFTP.Connect(); } catch (Exception ex) { AddLog("错误: " + ex.Message, 1); return; } AddLog($"FTP已连接到 {myFTP.Server}:{myFTP.Port}, 成功登录!"); Text = $"极简FTP [{myFTP.Server}:{myFTP.Port}]"; PreLoadRemoteTree(); }
private int allowRep;//是否允许替换? public FTPMainForm() { myFTP = null; LocalNode = RemoteNode = null; flag = LocalTreeAfterEdit.DefaultOptions; InitializeComponent(); LocalPathLabel.Text = ""; RemotePathLabel.Text = ""; PreLoadTree(); }