public void LoadRemoteYmls() { btn_reload.Enabled = false; ArrayList fileList = monitorForm.getDirFiles(remoteCfgPath); if (null != fileList) { if (fileList.Count > 0) { label1.Visible = false; listView1.Items.Clear(); ListViewItem item = null; ChannelSftp.LsEntry file = null; YmlFile yml = null; string remotePath = "", localPath = ""; for (int i = 0; i < fileList.Count; i++) { object obj = fileList[i]; if (obj is ChannelSftp.LsEntry) { file = (ChannelSftp.LsEntry)obj; try { yml = new YmlFile(); yml.correct = true; yml.localName = file.getFilename(); yml.localPath = cfgDir + "/"; yml.remoteName = file.getFilename(); yml.remotePath = remoteCfgPath + "/"; yml.status = YmlFileState.NoModif; item = new ListViewItem(); item.Text = file.getFilename(); item.Tag = yml; item.ImageIndex = 1; remotePath = yml.remotePath + yml.remoteName; localPath = yml.localPath + yml.localName; downloadFile(remotePath, localPath); listView1.Items.Add(item); } catch { } } } } else { label1.Text = "暂无文件"; label1.Visible = true; } } else { label1.Text = "加载失败"; label1.Visible = true; } btn_reload.Enabled = true; }