public DFtpResult Go() { String newName = IOHelper.AskString("Enter name for the new Directory:"); DFtpAction action = new CopyDirectoryRemoteAction(Client.ftpClient, Client.localDirectory, Client.remoteDirectory, Client.remoteSelection, newName); DFtpResult result = action.Run(); if (result.Type == DFtpResultType.Ok) { IOHelper.Message("The directory was successfully copied to '" + newName + "'."); Client.remoteSelection = null; } return(result); }
public void CopyDirTest() { EstablishConnection(); //check if dir already exists if (client.DirectoryExists("/JTest")) { client.DeleteDirectory("/JTest", FtpListOption.AllFiles); } //set local and remote paths String localdir = Path.GetTempPath(); String Remotedir = "/"; //create new directories with files CreatedeepDir(client); DFtpFile test = new DFtpFile("/Test", FtpFileSystemObjectType.Directory); //run the copy directory action DFtpAction action = new CopyDirectoryRemoteAction(client, localdir, Remotedir, test, "JTest"); DFtpResult result = action.Run(); //get the listings for all the directories we copied FtpListItem[] fluentListing = client.GetListing("/JTest", FtpListOption.AllFiles); FtpListItem[] fluentListing2 = client.GetListing("/JTest" + "/test2", FtpListOption.AllFiles); FtpListItem[] fluentListing3 = client.GetListing("/JTest" + "/test3", FtpListOption.AllFiles); FtpListItem[] fluentListing4 = client.GetListing("/JTest" + "/test3" + "/tesst", FtpListOption.AllFiles); FtpListItem[] fluentListing5 = client.GetListing("/JTest" + "/test3" + "/tesst" + "/finaltest", FtpListOption.AllFiles); //compare the file numbers in each directory Assert.True(fluentListing.Length == 5); Assert.True(fluentListing2.Length == 4); Assert.True(fluentListing3.Length == 5); Assert.True(fluentListing4.Length == 6); Assert.True(fluentListing5.Length == 6); //clean up client.DeleteDirectory("/JTest", FtpListOption.AllFiles); client.DeleteDirectory("/Test", FtpListOption.AllFiles); //make sure everything is cleaned up Assert.False(client.DirectoryExists("/JTest")); Assert.False(client.DirectoryExists("/Test")); }