问题
I have an FTP server from which I need to upload files to a blob storage in Azure. I cannot touch or move any of the files. Is there anyway to do an incremental scan (through an id or similar), or do you have to save the modified date of the newest file and then scan all files newer than that? All input are welcome.
回答1:
All you can do with FTP is to get a list of all files in a directory. Nothing else.
Some FTP servers will allow you retrieving the list sorted by a timestamp. This is a proprietary non-standard extension. See How to get files in FTP folder sorted by modification time. But it still won't save you from requesting a listing of all files (though you may abort the list download prematurely, once you get all files you need).
There's no way to ask an FTP server to return only "new files", no matter what's your definition of that.
If you need anything fancy, you will have to build a service on the server (server as a machine, not server as an FTP server) itself with an API that will do what you need.
来源:https://stackoverflow.com/questions/59790976/incremental-scan-of-new-modified-ftp-files-with-c-sharp