示例#1
0
 public void SyncEngineEventHandler(object sender, SyncToy.SyncEventArgs SEArgs)
 {
     if (SEArgs.Failed)
     {
         string Msg = string.Format("Error: {0}", SEArgs.Action.ToErrorText());
         Console.WriteLine(Msg);
     }
     else if (SEArgs.Action != null && SEArgs.PreviewMode)
     {
         if (prevOnly)
         {
             Console.WriteLine("{0},{1:N},{2},{3}", SEArgs.Action.Code,"", SEArgs.Action.SourceFullPath, SEArgs.Action.DestinationFullPath);
         }
         numActions++;
     }
     else if(SEArgs.Action != null && !SEArgs.PreviewMode)
     {
         PercentComplete++;
         Console.WriteLine("{0},{1:N},{2},{3}", SEArgs.Action.Code, (double)PercentComplete / numActions*100, SEArgs.Action.SourceFullPath, SEArgs.Action.DestinationFullPath);
     }
 }
示例#2
0
 private void SyncFolderPair(SyncToy.SyncEngineConfig Config, bool previewOnly)
 {
     PercentComplete = 0;
     try
     {
         SyncToy.SyncEngine Engine = new SyncToy.SyncEngine(Config);
         Engine.syncEvent += new SyncToy.SyncEventHandler(SyncEngineEventHandler);
         Engine.Preview();
         if (!previewOnly)
         {
             Engine.Sync();
         }
         Engine = null;
     }
     catch (Exception ex)
     {
         Console.WriteLine("SyncFolderPair Exception -> {0}", ex.Message);
     }
 }