0

Is there any way in C# to get the recent uploaded file? Whenever a new file is uploaded to the FTP, a trigger should be raised that this is the new file that is added. I achieved it at a level using FtpWebRequest and WINSCP (check for new files which has last modified date with in 5 minutes) but there is a use case which is failing here. Lets say a file is modified last on 01/01/2018 and I uploaded this file on FTP today then as per its last modified date it wont be processed. Is there any way by which I can check which file is uploaded recently.

Narendra Jangir
  • 233
  • 1
  • 5
  • 14
  • The target file system of the upload is on your system (or at least you can install your program there)? Or is it some remote one you only have access via FTP to? – sticky bit May 01 '18 at 12:05
  • A different perspective - Instead of you writing your custom code, why don't you explore the Azure Logic app FTP connector - https://learn.microsoft.com/en-us/azure/connectors/connectors-create-api-ftp? – user1672994 May 01 '18 at 12:06
  • @stickybit, it is remote file system which I can access via FTP. – Narendra Jangir May 01 '18 at 12:39
  • @user1672994,actually I am also facing the same issue in Azure Logic App FTP connector and thats why I am looking for a custom way. Logic app with trigger (when a new file added or modified) didn't run when file last modified date is older then today. If we see the trigger history then it is being shown as skipped step. – Narendra Jangir May 01 '18 at 12:46
  • @BobG, As per my understanding this approach will only work if we have access of FTP directory system as local directory system. FTP that I need to access is remote and I can access using FTP login. In all the solutions provided for the thread https://stackoverflow.com/questions/1239616/c-sharp-filesystemwatcher-and-ftp you can see that no one have written code to login to FTP, they all are treating it as a local file system. – Narendra Jangir May 01 '18 at 12:49

1 Answers1

0

You can only use the information that the FTP server provides you with. And it won't tell you, what files were added. If you cannot use file modification time, you are out of luck. Except maybe if the server provides a file creation (not modification) timestamp. But I do not know of any major FTP server that does.

So all you can do, is to remember a list of files on the server and compare a current list again a previous one, to find what files were added.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992