Код: Выделить всё
FluentFTP.Exceptions.FtpException
HResult=0x80131500
Message=Uploaded file checksum value does not match local file
Source=FluentFTP
StackTrace:
at FluentFTP.FtpClient.UploadFileFromFile(String localPath, String remotePath, Boolean createRemoteDir, FtpRemoteExists existsMode, Boolean fileExists, Boolean fileExistsKnown, FtpVerify verifyOptions, Action`1 progress, FtpProgress metaProgress)
at FluentFTP.FtpClient.UploadFile(String localPath, String remotePath, FtpRemoteExists existsMode, Boolean createRemoteDir, FtpVerify verifyOptions, Action`1 progress)
at gttXMLImportExportService.ClassFtpThread.PutFileListUsing_FluentFTP(String fileName) in C:Devops\WindowsServices\gttXMLImportExportService\ClassFtpThread.cs:line 522
This exception was originally thrown at this call stack:
FluentFTP.FtpClient.UploadFileFromFile(string, string, bool, FluentFTP.FtpRemoteExists, bool, bool, FluentFTP.FtpVerify, System.Action, FluentFTP.FtpProgress)
FluentFTP.FtpClient.UploadFile(string, string, FluentFTP.FtpRemoteExists, bool, FluentFTP.FtpVerify, System.Action)
gttXMLImportExportService.ClassFtpThread.PutFileListUsing_FluentFTP(string) in ClassFtpThread.cs
< /code>
< /blockquote>
Мой код таково: < /p>
using (FluentFTP.FtpClient ftpConnection = new FluentFTP.FtpClient())
{
FtpProfile ftpProfile = new FtpProfile();
ftpProfile.Credentials = new System.Net.NetworkCredential(_ftpDefinition.UserName, _ftpDefinition.PassWord);
ftpProfile.Host = _ftpDefinition.Host;
ftpProfile.Protocols = System.Security.Authentication.SslProtocols.Default;
ftpProfile.Encoding = System.Text.Encoding.UTF8;
ftpConnection.Port = _ftpDefinition.Port;
try
{
string currentFile = "";
string fileForLogging = "";
string remoteFile = "";
try
{
ftpConnection.Connect(ftpProfile);
//ftpConnection.SetWorkingDirectory(remoteDir);
foreach (string file in files)
{
fileForLogging = file;
currentFile = Path.GetFileName(file);
_fileName = currentFile;
remoteFile = remoteDir + @"/" + currentFile;
// HERE THE EXCEPTION IS THROWN
FtpStatus status = ftpConnection.UploadFile(file, remoteFile, FtpRemoteExists.Skip, false, FtpVerify.Throw);
if (status == FtpStatus.Success)
{
result = LogAndMoveFile(file, ClassDataBase.IMPORT_EXPORT_SUCCEEDED, "");
}
else
{
throw new Exception($"File Upload Status {status.ToString()}");
}
}
}
catch (Exception ex)
{
result = LogAndMoveFile(fileForLogging, ClassDataBase.IMPORT_EXPORT_FAILED, ex.Message);
}
}
finally
{
ftpConnection.Disconnect();
}
}
< /code>
Значение переменных, когда: < /p>
FtpStatus status = ftpConnection.UploadFile(file, remoteFile, FtpRemoteExists.Skip, false, FtpVerify.Throw);
- file = "c: \ test \ somefile.edi"
remotefile = "/in/somefile.edi" pilezer folder/br/>
Код: Выделить всё
FtpStatus status = ftpConnection.UploadFile(file, remoteFile, FtpRemoteExists.Skip, false, FtpVerify.None);
< /code>
или это: < /p>
FtpStatus status = ftpConnection.UploadFile(file, remoteFile);
Возможно ли, что файл есть, но я не вижу его с Filezilla по какой -то причине? Статус - это успех , но FileExists возвращает false .
Код: Выделить всё
FtpStatus status = ftpConnection.UploadFile(file, remoteFile, FtpRemoteExists.Skip, false, FtpVerify.None);
if (status == FtpStatus.Success)
{
if (ftpConnection.FileExists(remoteFile))
{
result = LogAndMoveFile(file, ClassDataBase.IMPORT_EXPORT_SUCCEEDED, "");
}
else
{
// HOW IS IT POSSIBLE I GET HERE ??????
throw new Exception($"File Upload Status is success, but the file is not uploaded");
}
}
Вот журнал от fluentftp для fileupload и fileexists :
Код: Выделить всё
[24/04/2025 15:18:02] [Info] > Connect(False)
[24/04/2025 15:18:02] [Verbose] FluentFTP 52.1.0.0(.NET Framework 4.7.2) FtpClient
[24/04/2025 15:18:02] [Verbose] Connecting(sync) FtpClient.FtpSocketStream(control) IP #1 = ***:10021
[24/04/2025 15:18:02] [Verbose] Waiting for a response
[24/04/2025 15:18:02] [Verbose] Response: 220-Welcome to the DINET FTP Server.
Response: 220-Please proceed to log in with the username
[24/04/2025 15:18:02] [Info] Response: 220 and password given to you by your trading partner. [739364,554d]
[24/04/2025 15:18:02] [Info] Command: AUTH TLS
[24/04/2025 15:18:02] [Verbose] Waiting for response to: AUTH TLS
[24/04/2025 15:18:02] [Info] Response: 500 Command not recognised. [18ms]
[24/04/2025 15:18:02] [Info] Command: USER ***
[24/04/2025 15:18:02] [Verbose] Waiting for response to: USER ***
[24/04/2025 15:18:02] [Info] Response: 331 Now please specify password. [20ms]
[24/04/2025 15:18:02] [Info] Command: PASS ***
[24/04/2025 15:18:02] [Verbose] Waiting for response to: PASS ***
[24/04/2025 15:18:03] [Info] Response: 230 Welcome to the EPIC FTP service. [98ms]
[24/04/2025 15:18:03] [Info] Command: FEAT
[24/04/2025 15:18:03] [Verbose] Waiting for response to: FEAT
[24/04/2025 15:18:03] [Info] Response: 500 Command not recognised. [20ms]
[24/04/2025 15:18:03] [Info] Text encoding: System.Text.SBCSCodePageEncoding
[24/04/2025 15:18:03] [Info] Command: SYST
[24/04/2025 15:18:03] [Verbose] Waiting for response to: SYST
[24/04/2025 15:18:03] [Info] Response: 215 UNIX EPIC [22ms]
[24/04/2025 15:18:03] [Verbose] Active ServerHandler is: None
[24/04/2025 15:18:03] [Verbose] Listing parser set to: Unix
[24/04/2025 15:18:03] [Info] Command: PWD
[24/04/2025 15:18:03] [Verbose] Waiting for response to: PWD
[24/04/2025 15:18:03] [Info] Response: 257 "/" [23ms]
[24/04/2025 15:18:03] [Info] > SetWorkingDirectory("/In")
[24/04/2025 15:18:03] [Info] Command: CWD /In
[24/04/2025 15:18:03] [Verbose] Waiting for response to: CWD /In
[24/04/2025 15:18:03] [Info] Response: 250 Current directory is now /In. [16ms]
[24/04/2025 15:18:03] [Info] > UploadFile("\\SRV-GTT-FILE01\PalmDocuments\EDI\Ford\VoertuigenAfmelden\GTT_20250421_135758_27942.EDI", "GTT_20250421_135758_27942.EDI", Skip, False, None)
[24/04/2025 15:18:03] [Info] > FileExists("GTT_20250421_135758_27942.EDI")
[24/04/2025 15:18:03] [Info] > GetNameListing("/In")
[24/04/2025 15:18:03] [Info] Command: TYPE I
[24/04/2025 15:18:03] [Verbose] Waiting for response to: TYPE I
[24/04/2025 15:18:03] [Info] Response: 200 Ok. [20ms]
[24/04/2025 15:18:03] [Info] > OpenDataStream("NLST /In", 0)
[24/04/2025 15:18:03] [Info] > OpenPassiveDataStream(PASV, "NLST /In", 0)
[24/04/2025 15:18:03] [Info] Command: PASV
[24/04/2025 15:18:03] [Verbose] Waiting for response to: PASV
[24/04/2025 15:18:03] [Info] Response: 227 (20,49,162,160,117,48) [290ms]
[24/04/2025 15:18:03] [Verbose] Connecting(sync) FtpClient.FtpSocketStream(data) IP #1 = ***:30000
[24/04/2025 15:18:03] [Info] Command: NLST /In
[24/04/2025 15:18:03] [Verbose] Waiting for response to: NLST /In
[24/04/2025 15:18:03] [Info] Response: 150 Opening data connection for transfer of information. [46ms]
[24/04/2025 15:18:03] [Verbose] +---------------------------------------+
[24/04/2025 15:18:03] [Verbose] Disposing(sync) FtpClient.FtpSocketStream(data)
[24/04/2025 15:18:03] [Info] > CloseDataStream()
[24/04/2025 15:18:03] [Verbose] Waiting for response to: NLST /In
[24/04/2025 15:18:03] [Info] Response: 226 Ok. [46ms]
[24/04/2025 15:18:03] [Verbose] -----------------------------------------
[24/04/2025 15:18:03] [Verbose] Disposing(sync) FtpClient.FtpSocketStream(data) (redundant)
[24/04/2025 15:18:03] [Info] > OpenWrite("GTT_20250421_135758_27942.EDI", Binary, -1, False)
[24/04/2025 15:18:03] [Info] > OpenDataStream("STOR GTT_20250421_135758_27942.EDI", 0)
[24/04/2025 15:18:03] [Info] > OpenPassiveDataStream(PASV, "STOR GTT_20250421_135758_27942.EDI", 0)
[24/04/2025 15:18:03] [Info] Command: PASV
[24/04/2025 15:18:03] [Verbose] Waiting for response to: PASV
[24/04/2025 15:18:03] [Info] Response: 227 (20,49,162,160,117,48) [26ms]
[24/04/2025 15:18:03] [Verbose] Connecting(sync) FtpClient.FtpSocketStream(data) IP #1 = ***:30000
[24/04/2025 15:18:03] [Info] Command: STOR GTT_20250421_135758_27942.EDI
[24/04/2025 15:18:03] [Verbose] Waiting for response to: STOR GTT_20250421_135758_27942.EDI
[24/04/2025 15:18:03] [Info] Response: 125 Data connection connected, starting transfer. [199ms]
[24/04/2025 15:18:03] [Verbose] Uploaded 1024 bytes, FileExists("GTT_20250421_135758_27942.EDI")
[24/04/2025 15:18:03] [Info] > GetNameListing("/In")
[24/04/2025 15:18:03] [Info] > OpenDataStream("NLST /In", 0)
[24/04/2025 15:18:03] [Info] > OpenPassiveDataStream(PASV, "NLST /In", 0)
[24/04/2025 15:18:03] [Info] Command: PASV
[24/04/2025 15:18:03] [Verbose] Waiting for response to: PASV
[24/04/2025 15:18:04] [Info] Response: 227 (20,49,162,160,117,48) [26ms]
[24/04/2025 15:18:04] [Verbose] Connecting(sync) FtpClient.FtpSocketStream(data) IP #1 = ***:30000
[24/04/2025 15:18:04] [Info] Command: NLST /In
[24/04/2025 15:18:04] [Verbose] Waiting for response to: NLST /In
[24/04/2025 15:18:04] [Info] Response: 150 Opening data connection for transfer of information. [41ms]
[24/04/2025 15:18:04] [Verbose] +---------------------------------------+
[24/04/2025 15:18:04] [Verbose] Listing: GTT_20250421_135758_27942.EDI
[24/04/2025 15:18:04] [Verbose] Disposing(sync) FtpClient.FtpSocketStream(data)
[24/04/2025 15:18:04] [Info] > CloseDataStream()
[24/04/2025 15:18:04] [Verbose] Waiting for response to: NLST /In
[24/04/2025 15:18:04] [Info] Response: 226 Ok. [51ms]
[24/04/2025 15:18:04] [Verbose] -----------------------------------------
[24/04/2025 15:18:04] [Verbose] Disposing(sync) FtpClient.FtpSocketStream(data) (redundant)
[24/04/2025 15:18:04] [Info] > Disconnect()
[24/04/2025 15:18:04] [Info] Command: QUIT
[24/04/2025 15:18:04] [Verbose] Waiting for response to: QUIT
[24/04/2025 15:18:04] [Info] Response: 221 Service is closing. [24ms]
[24/04/2025 15:18:04] [Verbose] Disposing(sync) FtpClient.FtpSocketStream(control)
[24/04/2025 15:18:04] [Info] > Dispose()
[24/04/2025 15:18:04] [Verbose] Disposing(sync) FtpClient
[24/04/2025 15:18:04] [Info] > Disconnect()
[24/04/2025 15:18:04] [Verbose] Connection already closed, nothing to do.
[24/04/2025 15:18:04] [Verbose] Disposing(sync) FtpClient.FtpSocketStream(control) (redundant)
Подробнее здесь: https://stackoverflow.com/questions/795 ... same-error