FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

Verifying Files from FTP to PC

Open Louisj99 opened this issue 5 years ago • 2 comments

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.

Louisj99 avatar Oct 30 '20 02:10 Louisj99

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 .

robinrodricks avatar Oct 30 '20 08:10 robinrodricks

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

Louisj99 avatar Oct 30 '20 19:10 Louisj99

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!

robinrodricks avatar Sep 19 '22 14:09 robinrodricks