Verifying Files from FTP to PC
FTP OS: Windows
Computer OS: wins 10
FluentFTP Version: Latest as of 30/10/20
Hi, I'm currently trying to verify the files on a PC are the same as the files on the FTP server. I'm trying to use checksum so that the file size doesn't matter however I am yet to come across a method on how to replace files that are existing on the PC but have been updated on the FTP. It downloads new files and deletes files on the PC that are not needed but if the same file already exists it fails to check if it has been updated and needs to be downloaded.
this is what I am currently doing to download and try to check what is on the PC.
` FtpClient client = new FtpClient("12.12.12.12");
client.Credentials = new NetworkCredential("anonymous", "anonymous");
foreach (FtpListItem item in client.GetListing("/@ExampleLocation"))
{
if (item.Type == FtpFileSystemObjectType.File)
{
FtpHash hash = client.GetChecksum(item.FullName);
}
}
client.Connect();
// not used atm
FtpCompareResult compareResult = client.CompareFile(@FileLocation, @"/@ExampleLocation", FtpCompareOption.Checksum);
string fileLocation = @FileLocation;
client.DownloadDirectory(fileLocation, @"/@ExampleLocation", FtpFolderSyncMode.Mirror, (FtpLocalExists)FtpVerify.Retry, FtpVerify.Delete);`
any help is appreciated, I know this might not be the place to post this but I wasn't sure where else to post it.
So you want like a CompareDirectory method?
On Fri, Oct 30, 2020, 7:51 AM Louis-LF [email protected] wrote:
FTP OS: Windows
Computer OS: wins 10
FluentFTP Version: Latest as of 30/10/20
Hi, I'm currently trying to verify the files on a PC are the same as the files on the FTP server. I'm trying to use checksum so that the file size doesn't matter however I am yet to come across a method on how to replace files that are existing on the PC but have been updated on the FTP. It downloads new files and deletes files on the PC that are not needed but if the same file already exists it fails to check if it has been updated and needs to be downloaded.
this is what I am currently doing to download and try to check what is on the PC.
` FtpClient client = new FtpClient("12.12.12.12"); client.Credentials = new NetworkCredential("anonymous", "anonymous");
foreach (FtpListItem item in client.GetListing("/@ExampleLocation")) { if (item.Type == FtpFileSystemObjectType.File) { FtpHash hash = client.GetChecksum(item.FullName); } } client.Connect(); // not used atm FtpCompareResult compareResult = client.CompareFile(@FileLocation, @"/@ExampleLocation", FtpCompareOption.Checksum); string fileLocation = @FileLocation; client.DownloadDirectory(fileLocation, @"/@ExampleLocation", FtpFolderSyncMode.Mirror, (FtpLocalExists)FtpVerify.Retry, FtpVerify.Delete);`any help is appreciated, I know this might not be the place to post this but I wasn't sure where else to post it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/robinrodricks/FluentFTP/issues/639, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT3UKUNPWFZBLV52IOM56LSNIPLXANCNFSM4TEOXKCQ .
Yeah, the only issue atm is that if the name of the file doesn't change then it won't try to reinstall it so yeah a comparedirectory method would work
Added to the bucket list. We will pick this up as and when we have free time. Comment on this issue if you want us to prioritize it. Thanks!