Synchronize each directories

Advertisement

captaincoooper
Joined:
Posts:
5

Synchronize each directories

Good day Martin!

Thank you once again.

I don't know if the assembly supports file synchronization. So I'm playing around with SynchronizationDirectories. But it synchronize only the target remote directory.

I'm looking for a way to synchronize each local directory to remote directory. I can walk each directories but I just want to sync the files only. Do you have any idea if this is possible.

My Objective here is to be able to track the progress of the FTP synchronization.

Unlike uploading, I can create background workers to upload each files. In this way, file uploading will be a little faster.

Thanks you.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Synchronize each directories

Sorry, I do not understand. What does "I just want to sync the files only" mean that you cannot do it with Session.SynchronizeDirectories?

Reply with quote

captaincoooper
Joined:
Posts:
5

Re: Synchronize each directories

martin wrote:

Sorry, I do not understand. What does "I just want to sync the files only" mean that you cannot do it with Session.SynchronizeDirectories?

I'm using Session.SynchronizeDirectories to synch files. But's gonna be slow because it's a single session. I want to SynchronizeDirectories using 4 Sessions. I'm thinking of synchronizing from the root directory but i want subdirectories to be excluded (using filemasking). In short i'm going to sychronize them each using 4 theads. It is it possible or do you have any alternative ideas.

thanks & regards

Reply with quote

captaincoooper
Joined:
Posts:
5

Re: Synchronize each directories

Hi Martin - I've got this working already. Yes, the file mask do the trick. Now I got multiple backgroundworkers doing the job = faster operation. here's the piece of code below

public void Synchronize()
{
//this.TransferOptions.FileMask = "*.* | */";
string localpath = WebsiteFileInfo.DirInfo.FullName + @"\";
localpath = localpath.Replace(@"\\", @"\");
this.TransferOptions.FileMask = string.Format(@"{0}*.* | {1}/*/", localpath, WebsiteFileInfo.RemotePath);
SynchronizationResult synchronizationResult;
synchronizationResult = _ftpSession.SynchronizeDirectories(SynchronizationMode.Remote, WebsiteFileInfo.DirInfo.FullName, WebsiteFileInfo.RemotePath, this.DeleteObsoleteFiles, this.Mirror, this.SynchronizationCriteriaOptions, this.TransferOptions);
try
{
synchronizationResult.Check();
}
catch (System.Exception e)
{
this.WebsiteFileInfo.Error = string.Format("{0}", e);
}
//
_transfersCount = synchronizationResult.Uploads.Count;
_failuresCount = synchronizationResult.Failures.Count;
//
this.WebsiteFileInfo.Processed = true;
this.IsBusy = false;
}


Cheers!

:D :D :D

Reply with quote

Advertisement

You can post new topics in this forum