Renci.SshNet.dll试图将文件上传到正确的位置 [英] Renci.SshNet.dll Trying to upload file to correct location
问题描述
您好,
我无法将文本文件上传到正确的位置我可以通过FileZilla查看位置。我编写了一个运行名为'UploadToFTPSite'的方法的测试脚本,这是TEST SCRIPT代码:
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()
{
//Arrange
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 = "*****";
//Assign
IbxUploadController.UploadToFTPSite(fileFolder, fileName, stringData, host, port, user, password);
//Assert
}
这是我的方法我试图运行:
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)
//etc.
问题是我可以将文件上传到根文件夹,但我'我试图在根文件夹中指定一个子文件夹来上传我的文件,但我无法将我的文件上传到除根文件夹之外的任何文件夹。我认为它可能与Client.WorkingDirectory有关,即使我调试它时客户端有我想要文件的位置。
$ b $谢谢。任何建议将不胜感激!
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!
推荐答案
不确定它是否是相同的错误,但我只是将远程目录添加到文件名本身,以便我的上传工作。
更改目录似乎对当前目录没有影响。
Not sure if it is the same error but I just added the remote directory to the file name itself for my upload to work.
Change Directory seems to have no effect on the current directory.
这篇关于Renci.SshNet.dll试图将文件上传到正确的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!