private void BWOnDoWork(object sender, DoWorkEventArgs e) { if (!(e.Argument is NodeListItem)) { return; } var src = e.Argument as NodeListItem; var list = new List <Xisoftp.FTPDirList>(); if (!Xisoftp.GetDirListing(src.Src, ref list)) { e.Result = Xisoftp.LastError; return; } foreach (var ftpDirList in list) { var node = new TreeNode(ftpDirList.Name) { ImageKey = ftpDirList.IsDirectory ? "folder" : "file", SelectedImageKey = ftpDirList.IsDirectory ? "folder" : "file" }; switch (src.Src) { case null: AddNewNode(node); break; default: AddNewChildNode(node, src.Node); break; } } }