public void PutMultipleTest() { //Create and put 3 files on local machine. List <DFtpFile> files = new List <DFtpFile>(); for (int i = 0; i < 3; ++i) { files.Add(CreateFileOnLocal()); } // Get multiple files from the directory DFtpAction listingAction = new GetListingLocalAction(LocalTestDirectory, true); DFtpResult tempList = listingAction.Run(); DFtpListResult listResult = null; if (tempList is DFtpListResult) { listResult = (DFtpListResult)tempList; List <DFtpFile> list = listResult.Files.Where(x => x.Type() == FtpFileSystemObjectType.File).ToList(); DFtpAction action = new PutMultipleAction(client, list, RemoteTestDirectory, true); DFtpResult result = action.Run(); if (result is DFtpListResult) { listResult = (DFtpListResult)result; Assert.True(listResult.Files.Count == 3); } else { return; } } else { return; } foreach (DFtpFile file in files) { // Delete each file RemoveFileOnServer(client, file); // Make sure it's gone Assert.False(SearchForFileOnServer(client, file.GetName())); } if (client.DirectoryExists(RemoteTestDirectory)) { client.DeleteDirectory(RemoteTestDirectory); } return; }
public DFtpResult Go() { // Get listing for remote directory DFtpAction getListingAction = new GetListingLocalAction(Client.localDirectory, Client.view_hidden); DFtpResult tempResult = getListingAction.Run(); if (tempResult.Type == DFtpResultType.Ok) { DFtpListResult listResult = null; if (tempResult is DFtpListResult) { listResult = (DFtpListResult)tempResult; List <DFtpFile> list = listResult.Files.Where(x => x.Type() == FtpFileSystemObjectType.File).ToList(); List <DFtpFile> selected = new List <DFtpFile>(); selected = IOHelper.SelectMultiple("Select multiple files to upload!(Arrow keys navigate, spacebar selects/deselects, enter confirms the current selection.)", list, false); if (selected.Count == 0) { IOHelper.Message("No files selected."); return(new DFtpResult(DFtpResultType.Ok)); } DFtpAction action = new PutMultipleAction(Client.ftpClient, selected, Client.remoteDirectory, true); // Carry out the action and get the result DFtpResult result = action.Run(); // Give some feedback if successful if (result.Type == DFtpResultType.Ok) { IOHelper.Message("files uploaded successfully."); } return(result); } else { return(new DFtpResult(DFtpResultType.Error, "Error on the operation.")); } } else { return(new DFtpResult(DFtpResultType.Error, "Error on the operation.")); } }