Check if file was updated with .Net Core in a Linux Server using C#

favosys :

I'm doing a .Net Core app that needs to check if certain files were recently replaced. Basically check if the files were replaced with a newer version (it might be the same file or have the same size but it was replaced for some reason).

I uploaded a file to the server today March 4th 2020 at 12:32 pm and then tried using File.GetLastWriteTime but it gives me Feb 27 2019 which is probably when the file was originally created or when I downloaded it to my PC. I tried File.GetLastAccessTime and File.GetCreationTime but I get the same result:

Image 1

If I run stat I can see the date I need (Change):

Image 2

But I don't know how to get it. Ideally I would get it with C# but I guess running a linux command to get this date is an option. I did some research and found: stat -c and date -r but they don't give me the date I need.

Image 3

Image 4

How can I detect if the file was recently replaced using C# or worst case scenario a linux command that will give me just the "change" date?

favosys :

I didn't get any answer here so I ended up running the stat command from within the .Net Core application, capturing the output and extracting the date from the "Change" section.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=220079&siteId=1