private void sbImportSsh_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog(); ofd.Title = "SSH File"; ofd.Filter = "SSH File|*.txt"; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.Cancel) { return; } teImportPath.Text = ofd.FileName; var sshFile = File.ReadAllLines(ofd.FileName); listSsh = new List <SshDetails>(); var builder = new StringBuilder(); foreach (var item in sshFile) { var ssh = new SshDetails(); var splitLine = item.Split('|'); ssh.Host = splitLine[0]; ssh.Username = splitLine[1]; ssh.Password = splitLine[2]; builder.AppendLine($"{ssh.Host}|{ssh.Username}|{ssh.Password}"); listSsh.Add(ssh); } teTotalSsh.Text = listSsh.Count().ToString(); File.WriteAllText(SettingStatic.Instance.sshUnused, builder.ToString()); sbStop.Enabled = false; changeMultiThread.sshUSed.Clear(); }
private IEnumerable <SshDetails> GetListSshFromFile() { var fileSsh = File.ReadAllLines(SettingStatic.Instance.sshUnused); foreach (var item in fileSsh) { var ssh = new SshDetails(); var split = item.Split('|'); ssh.Host = split[0]; ssh.Username = split[1]; ssh.Password = split[2]; yield return(ssh); } }