#c# #chilkat
#c# #chilkat
Вопрос:
РЕДАКТИРОВАТЬ: найдена проблема. Я не вводил всю структуру папок при попытке сохранить файл. Теперь проблема решена.
Я пытаюсь загрузить файл с помощью 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
Комментарии:
1. Все ли клиенты находятся на одном сервере? Если нет, то действительно ли сервер использует sftp, а не ftp — в этом случае chilkat может не сработать. Кроме того, похоже, что вы можете включить подробное ведение журнала для сообщения об ошибке.
2. Привет. Не все клиенты находятся на одном сервере, нет.