If you have access to the file system of a remote system with a UNC path (for example, \\remotehost\foo\bar , for example, using Windows Explorer), you can get a remote datetime , even if it is not a Windows system , followed by workaround. Create a dummy file, read its recording time and discard it. It also works for the local host.
public DateTime filesystemDateTime(string path) { //create temp file string tempFilePath = Path.Combine(path, "lampo.tmp"); using (File.Create(tempFilePath)) { } //read creation time and use it as current source filesystem datetime DateTime dt = new FileInfo(tempFilePath).LastWriteTime; //delete temp file File.Delete(tempFilePath); return dt; }
bluish
source share