问题
I'm using WinSCP .NET assembly in my C# WinForms application and I want to synchronize my remote directory with my local directory. This works great with WinSCP.
But before the synchronisation starts, I want to check if the remote and the locale directors are different at all. To do this, I want to use the CalculateFileChecksum()
method from WinSCP. Here is an example for what I'm trying to do.
And here is the code, where I call the method:
var checksum =
session.CalculateFileChecksum("md5", Properties.Settings.Default.ftpServerModDir);
The first string is the algorithm for calculating the checksum, the second is the remote path.
If I run this code, I get the following exception.
Operation not supported.
It looks like, my FTP server does not support MD5, but this table says that FTP should support the following
Supported (HASH, XSHA1, XSHA256, XSHA512, MD5, XMD5, XCRC).
I tried HASH, MD5 and XMD5 already but always get the same exception.
Has anyone an idea how to get this working? Or how can I check which algorithm my server supports?
Thanks for your help!
回答1:
how can I check which algorithm my server supports?
Connect with WinSCP GUI to your server, pick a file and go to Files > Properties, select Checksum tab. And see, what algorithms the GUI offers:
Use algorithm name as shown in the dialog, if any is shown is all. If none is shown, you cannot use the CalculateFileChecksum.
Note that you use an algorithm name in the CalculateFileChecksum
(like md5
or sha-1
), you do not use an FTP command name (like XMD5
, XSHA1
).
Note that it's quite likely, that your server does not support checksum calculation at all, as MD5 is by far the most widely used one. So if MD5 is not supported, it's not likely that any other is.
but this table says that FTP should support the following
Supported (HASH, XSHA1, XSHA256, XSHA512, MD5, XMD5, XCRC).
The table says that WinSCP supports those FTP commands to calculate a checksum. None of these commands are actually standardized and FTP server is not required to support any of them.
See FTP: copy, check integrity and delete.
Also, note that you cannot use CalculateFileChecksum
for a directory, only for a file.
来源:https://stackoverflow.com/questions/43260159/winscp-checksum-calculation-operation-not-supported