public static List <SessionData> GetAllSessionsFromPuTTYCM(string fileExport) { List <SessionData> sessions = new List <SessionData>(); if (fileExport == null || !File.Exists(fileExport)) { return(sessions); } XmlDocument doc = new XmlDocument(); doc.Load(fileExport); XmlNodeList connections = doc.DocumentElement.SelectNodes("//connection[@type='PuTTY']"); foreach (XmlElement connection in connections) { List <string> folders = new List <string>(); XmlElement node = connection.ParentNode as XmlElement; while (node != null && node.Name != "root") { if (node.Name == "container" && node.GetAttribute("type") == "folder") { folders.Add(node.GetAttribute("name")); } node = node.ParentNode as XmlElement; } folders.Reverse(); string parentPath = string.Join("/", folders.ToArray()); XmlElement info = (XmlElement)connection.SelectSingleNode("connection_info"); XmlElement login = (XmlElement)connection.SelectSingleNode("login"); SessionData session = new SessionData { SessionName = info.SelectSingleNode("name").InnerText, Host = info.SelectSingleNode("host").InnerText, Port = Convert.ToInt32(info.SelectSingleNode("port").InnerText), Proto = (ConnectionProtocol) Enum.Parse(typeof(ConnectionProtocol), info.SelectSingleNode("protocol").InnerText), PuttySession = info.SelectSingleNode("session").InnerText }; session.SessionId = string.IsNullOrEmpty(parentPath) ? session.SessionName : SessionData.CombineSessionIds(parentPath, session.SessionName); session.Username = login.SelectSingleNode("login").InnerText; sessions.Add(session); } return(sessions); }