It is possible to get a local server time using FTP? I am on Smart device project in .NET and using Exceed FTP library, unfortunately these are my limitations. System.File.IO is not available to be used in Compact framework.
I first created a file on a local machine, FTPed it over to the server and copied it back.
FtpFolder destTimestampFolder = new FtpFolder(ftpConn,
ConfigReader.AppSettings["inDir"]+"\\timestamp");
AbstractFile localttfile = new DiskFile(ConfigReader.AppSettings["mainPath"] + ConfigReader.AppSettings["clientConfigDir"] + "\\timestamp.txt");
if (!localttfile.Exists)
{
localttfile.Create();
}
localttfile.CopyTo(destTimestampFolder, true);
// copy back and grab the last accessed timestamp
AbstractFile destttfile = rootFolder.GetFile(ConfigReader.AppSettings["inDir"] + "\\timestamp\\timestamp.txt");
destttfile.CopyTo(destFolder, true);
MessageBox.Show(localttfile.LastAccessDateTime.ToString());
The timestamp displayed shows me in the local machine time. I tried showing destttfile.LastAccessDateTime and it gives me zeros.
Any workaround would be helpful. I basically would like to get a last accessed file stamp and calculate the difference.
No, FTP protocol does not have a way to retrieve server clock.
There are two possibilities:
MLSTorMDTMcommands which should return UTC timestamps of a file.Some (few) FTP servers allow existing some/arbitrary shell commands. You might be able to use that to retrieve the server's time.
Otherwise, you will have to use another service instead of FTP (some web service for example).