internal DFtpFile CreateAndPutFileInDirectoryOnServer(FtpClient ftpClient, String remoteDirectory = testDirectory) { String filepath = Path.GetTempFileName(); String localDirectory = Path.GetDirectoryName(filepath); DFtpFile localSelection = new DFtpFile(filepath, FtpFileSystemObjectType.File); DFtpAction action = new PutFileAction(client, localDirectory, localSelection, remoteDirectory); DFtpResult result = action.Run(); return(localSelection); }
/// <summary> /// Attemps to upload a file from the client context to the remote server. /// </summary> /// <returns>A DftpResult object containing an OK or ERROR with a message of the /// resulting operation.</returns> public DFtpResult Go() { // Create the action. Initialize it with the info we've collected DFtpAction action = new PutFileAction(Client.ftpClient, Client.localDirectory, Client.localSelection, Client.remoteDirectory); DFtpResult result = action.Run(); // Give some feedback if successful if (result.Type == DFtpResultType.Ok) { IOHelper.Message("The file '" + Client.localSelection.GetName() + "' uploaded successfully."); } // Return the result after running. return(result); }