РЕДАКТИРОВАТЬ: нашел проблему.
Я не набирал всю структуру папок при попытке сохранить файл.
Теперь проблема решена.
Я пытаюсь загрузить файл с помощью c # и chilkat клиенту, но получаю код ошибки.
Я работаю в логистической компании, и у нас есть много типов интеграции с нашими клиентами. Некоторое время мы используем c # и chilkat, и это работает с каждым нашим клиентом. Это новый клиент, но я сделал тесты с использованием FileZilla, и все работает (создать, удалить, загрузить, загрузить), учетные данные совпадают.
Наша лицензия на Chilkat обновлена (сегодня), и у нас есть последняя версия.
Я протестировал с другими клиентами тот же код, и он работает (более 10 других клиентов)
string username = "login";
string password = "pass";
Chilkat.SFtp sftp = new Chilkat.SFtp();
bool success = sftp.UnlockComponent("Hello World");
if (success != true)
throw new Exception("Invalid License");
sftp.ConnectTimeoutMs = 5000;
sftp.IdleTimeoutMs = 10000;
success = sftp.Connect("address", 22);
if (success != true)
throw new Exception("Host could not be reached. Invalid Host.");
success = sftp.AuthenticatePw(username, password);
if (success != true)
throw new Exception("Invalid Credentials.");
success = sftp.InitializeSftp();
if (success != true)
throw new Exception("Connection could not be initialized.");
string[] fileList = Directory.GetFiles(@"c:\files\");
foreach (string item in fileList)
{
string handle = sftp.OpenFile("IN/" + Path.GetFileName(item), "writeOnly", "createTruncate");
if (handle == null)
{
string lastErrorText = sftp.LastErrorText;
//throw new Exception("Could not create a handle for the desired file");
}
else
{
success = sftp.UploadFile(handle, item);
if (success != true)
throw new Exception("Could not Upload the File");
else
Console.WriteLine("File {0} uploaded", item);
success = sftp.CloseHandle(handle);
if (success != true)
throw new Exception("Could not close the handle");
else
File.Delete(item);
}
}
Я ожидал, что файл будет загружен, но не получится.
Переменная LastErrorText возвращается со следующим текстом:
ChilkatLog:
OpenFile:
DllDate: Mar 18 2019
ChilkatVersion: 9.5.0.77
UnlockPrefix: Start my 30-day Trial
Architecture: Little Endian; 32-bit
Language: .NET 4.6 / x86 / VS2017
VerboseLogging: 0
SshVersion: SSH-2.0-SSHD-CORE-1.7.0
SftpVersion: 3
sftpOpenFile:
remotePath: IN/214KCF_S903211745.txt
access: writeOnly
createDisposition: createTruncate
v3Flags: 0x1a
Sent FXP_OPEN
StatusResponseFromServer:
Request: FXP_OPEN
InformationReceivedFromServer:
StatusCode: 3
StatusMessage: operation not permitted
--InformationReceivedFromServer
--StatusResponseFromServer
--sftpOpenFile
Failed.
--OpenFile
--ChilkatLog