I'm using the WinSCP .NET assembly to programmatically connect to a remote server and get the timestamp (or last update date) of a particular file. I have not been successful in finding a method call.
Asked
Active
Viewed 669 times
1 Answers
0
To get a timestamp of a single file use the LastWriteTime
property of the RemoteFileInfo
class instance returned by the Session.GetFileInfo
:
Console.WriteLine(session.GetFileInfo("/etc/passwd").LastWriteTime)
To get timestamps of all files in a directory, iterate the collection of the RemoteFileInfo
instances returned by the Session.ListDirectory
:
foreach (RemoteFileInfo fileInfo in session.ListDirectory("/etc").Files)
{
Console.WriteLine(fileInfo.LastWriteTime);
}

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