Get the latest sharepoint file without knowing the filename

I wan to get the latest modified file from a folder on sharepoint, but I don’t know the name of the file.

the story:
Person A uploades a file on a folder every month, and person B have to download that file.
There are 20 people like person A, they will upload to their own folder and I have to get into every folder and get the latest version.
I know how to get into every folder, but how to get the latest file in every folder, without knowing the file name, that’s the tricky part.

@Palaniyappan can you help me?

Hi, you can get a list of files for each folder using Directory.GetFiles(strYourFolderPath) and then loop the files using Directory.GetLastWriteTime(strYourFilePath). This returns a date object that indicates the last time the file was modified. You just need to find which file has the most recent date.

Thank you, it gives me the error message:

Log Message: The given path’s format is not supported.

this is in sharepoint, from here i have go through every folder and get the latest file;

Would it be posible to syncronize the main folder of the sharepoint to a folder in your local?

That’s a great idea to download it locally, thank you. But how can I open the latest file from there and check some condition in it? :slight_smile:

am I doing anything completely wrong?