/// <summary> /// Create a new ftp directory within the directory of the /// currently selected tree node. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void butNewFolder_Click(object sender, EventArgs e) { FullPath dirPath = SelectedFolderPath; using (FtpClient fc = GetFtpClient(dirPath)) { fc.MakeDirectory("NewFolder"); FtpResponse_DirList dirList = fc.GetDirList("NewFolder*"); foreach (FtpDirEntry de in dirList.RcvdDirList) { string s1 = de.EntryName; if (s1 == "NewFolder") { TreeNode node = mFtpDirTree.SelectedNode; string s2 = Path.Combine(dirPath.ToString(), de.EntryName); FullPath filePath = new FullPath(s2); TreeNode newNode = node.Nodes.Add(de.EntryName); newNode.Tag = filePath; } } } }
// ----------------------- FtpDirTree_FillDirNode ------------------------ void FtpDirTree_FillDirNode( FtpClient InFtpClient, string InFolderName, TreeNode InDirNode) { FtpClient fc = InFtpClient; fc.ChangeDirectory(InFolderName); FtpResponse_DirList dirList = fc.GetDirList(); foreach (FtpDirEntry de in dirList.RcvdDirList) { if (de.EntryType == AcFileType.Folder) { TreeNode node = InDirNode.Nodes.Add(de.EntryName); } } fc.ChangeDirectory(".."); }
// ----------------------- FtpDirTree_FillDirNode ------------------------ void FtpDirTree_FillDirNode( FullPath InDirPath, TreeNode InDirNode) { using (FtpClient fc = GetFtpClient(InDirPath)) { FtpResponse_DirList dirList = fc.GetDirList(); foreach (FtpDirEntry de in dirList.RcvdDirList) { if (de.EntryType == AcFileType.Folder) { string s1 = Path.Combine(InDirPath.ToString(), de.EntryName); FullPath filePath = new FullPath(s1); TreeNode node = InDirNode.Nodes.Add(de.EntryName); node.Tag = filePath; // add a dummy child node. This cause a plus sign to be displayed // next to the folder node. TreeNode subNode = node.Nodes.Add("empty"); subNode.Tag = "empty"; } } } }
/// <summary> /// return the directory info of a file or folder. /// </summary> /// <param name="InFileName"></param> /// <returns></returns> public FtpDirEntry GetFileInfo(string InFileName, AcFileType InFileType) { FtpDirEntry info = null; string fileName = InFileName; if (InFileType == AcFileType.Folder) { fileName = fileName + "*"; } FtpResponse_DirList dl = this.GetDirList(fileName); foreach (FtpDirEntry de in dl.RcvdDirList) { if (de.EntryName.ToLower() == InFileName.ToLower()) { info = de; break; } } return(info); }
/// <summary> /// returns the last change date of file or folder. /// </summary> /// <param name="InFileName"></param> /// <returns></returns> public DateTime GetChangeDateTime(string InFileName) { DateTime chgDttm = new DateTime(1, 1, 1); string fileName = InFileName; if (Pather.IsDirectoryName(fileName) == true) { fileName = fileName + "*"; } FtpResponse_DirList dl = this.GetDirList(fileName); foreach (FtpDirEntry de in dl.RcvdDirList) { if (de.EntryName.ToLower( ) == InFileName.ToLower( )) { chgDttm = de.ChgDateTime; break; } } return(chgDttm); }