Hello,
I'm having trouble ftp(ing) uploading a text file to the correct location I can view the locations via FileZilla. I wrote a test script that runs a method called 'UploadToFTPSite' this is the TEST SCRIPT code:
public void UploadToFTPSiteSuccess()
{
var ibxMedOut = IbxUploadController.GetDataToUpload();
var stringData = IbxUploadController.ConvertDataToString(ibxMedOut);
string fileFolder = "ibxuploadFolder";
string fileName = "Test.txt";
string host = "99.9.9.99";
int port = 22;
string user = "*****";
string password = "*****";
IbxUploadController.UploadToFTPSite(fileFolder, fileName, stringData, host, port, user, password);
}
This my is my Method I'm trying to run:
public static void UploadToFTPSite(string pFileFolder, string pFileName, string pContents, string pHost, int pPort, string pUser, string pPassword)
{
string currentProcess = "Starting";
try
{
ConnectionInfo connectionInfo = new PasswordConnectionInfo(pHost, pPort, pUser, pPassword);
currentProcess = "ConnectionInfo created";
string pather;
using (var client = new SftpClient(connectionInfo))
{
currentProcess = "SftpClient created";
client.Connect();
currentProcess = "Connected";
currentProcess = "WorkingDirectory: " + client.WorkingDirectory;
client.ChangeDirectory(pFileFolder);
client.Create(pFileName);
client.AppendAllText(pFileName, pContents);
currentProcess = "Data appended";
client.Disconnect();
currentProcess = "Disonnected";
}
}
catch (Exception ex)
The problem is I can upload my file to the root folder, but I'm trying to specify a sub folder inside the root folder to upload my file to, but I can't get my file to upload to a any folder but the root folder. I think it may have something to do with the "Client.WorkingDirectory" even though when I debug it the Client has the location where I want the file to go to.
Thanks. Any suggestions would be appreciated!