Topic "Synchronize each directories"

Author Message
captaincoooper
[View user's profile]

Joined: 2012-07-11
Posts: 5
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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Sorry, I do not understand. What does "I just want to sync the files only" mean that you cannot do it with Session.SynchronizeDirectories?
_________________
Martin Prikryl
captaincoooper
[View user's profile]

Joined: 2012-07-11
Posts: 5
prikryl 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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
Yes, you can use file mask with Session.SynchronizeDirectories.
_________________
Martin Prikryl
captaincoooper
[View user's profile]

Joined: 2012-07-11
Posts: 5
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!

Very Happy Very Happy Very Happy
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License