|
Dear Friends,
Greetings ....
(I am a new to this and need your kind help)
I am trying synctoy 2.1(x64) on windows7 64bit.
my SyncToyDirPairs.bin located as below -
C:\Users\sachin\AppData\Local\Microsoft\SyncToy\2.0\SyncToyDirPairs.bin
Please let me know if you have compatible executable.
Thanks a lot for your valuable help.
Sachin
|
|
|
|
|
On my machine the configuration is stored in the "c:\Documents and Settings\[username]\Local Settings\Application Data\Microsoft\SyncToy\2.0\SyncToyDirPairs.bin" file.
|
|
|
|
|
If you have trouble using the supplied configuration, you can use your own configuration file and substitute it on the following properties:
Dim sc As New SyncToy.SyncEngineConfig
'You can substitute here your own configuration variable
sc.LeftDir = "c:\log" 'left directory
sc.RightDir = "d:\logs" 'right directory
sc.Name = "my logs" 'name of your directory pair
sc.SyncMode = SyncMode.Synchronize 'what option (sync? echo? or contribute)
se1 = New SyncToy.SyncEngine(sc)
se1.Preview()
se1.Sync()
|
|
|
|
|
System gives error messages on sync
|
|
|
|
|
Synctoy writes to the Immidiate window that it's comparing two folders. Then my program just times out...
I get this error message:
The CLR has been unable to transition from COM context 0x20aee8 to COM context 0x20b058 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations.
|
|
|
|
|
I'm getting the same error. Do you ever resolve it?
|
|
|
|
|
Hi guys,
this is an excellent approach.
For my project, I need to delete Syntoy's folder pairs without knowing their exact names.
And I need to do it from within a vbs script (WSH). (How) Is that possible?
Any ideas how to deserialize and search for folder pair names in SyncToyDirPairs.bin or such?
I don't want to manipulate the file or actually start anything. Just learn the folder pair names...
Oliver
|
|
|
|
|
You might be able to do that in VBS. Try CreateObject("SyncToy.SyncEngine") Most of the rest of the code would remain the same.
It's been a while now since I've used SyncToy, but I beleive the folder names you're looking for are in a plain-text file somewhere. If it's not in the bin file, run FileMon to track it down. For some reason I'm thinking the file is within your user profile somewhere... (Documents and Settings\username\Application Data....)
Good luck.
|
|
|
|
|
Hi Domenic,
thank you.
I am too dumb to make it happen.
The following short script
----
dim syntoyeng
set syntoyeng=WScript.CreateObject("SyncToy.SyncEngine")
----
... brings up an error:
Could not locate automation class name "SyncToy.SyncEngine".
Is there anything i have to do before trying to create this object?
Could you perhaps provide a small example script, please?
I also FileMon'ed the creation of a SyncToy 2.0 folder pair to find the "plain text" file that you talked about, but I could not find any.
The SyncToyDirPairs.bin and SyncToyLog.log files are located in the same dir.
The log file does not contain any data about folder pairs (even not when changing the config file trace level from "Info" to "Verbose".
And I have difficulties to analyze the bin file from within my script as it is not a plain text file. And I don't have a clue how to deserialize this file from within WSH scripts...
Any help would be appreciated.
Thank you in advance,
Oliver
|
|
|
|
|
Maybe it will be a stupid question, but...
I cant use the program, im using visual basic express 2008 and I have a problem with the source, after add the DLL I recive an error in this part of code:
System.Diagnostics.EventLog.WriteEntry("SyncToy", se1.StatSummary, EventLogEntryType.Information)
se1.StatSummary is not a member of 'SyncToy.SyncEngine'
Can anybody help me? Im trying to make a USB utilities program.
Thanks
|
|
|
|
|
Never comes back. Anyone have this issue?
|
|
|
|
|
Excellent article and code.
I have imported it into a project i have been working on successfully and have had success with it - Thanks
Quick Question - has anyone tried updating the last run datetime and have the new value display against a folder pair within the synctoy application?
There are only 10 types of person in this world
Those that understand binary and those that don’t!
|
|
|
|
|
Hi,
I think this code is fantastic. I am adding an additional challenge though. What if you are able to create a service that constantly listens for changes in the right and left directories, and triggers the synchronization if something changes on either side?
I accomplished this using windows service. The service reads the configuration file and puts all the pairs in listening mode, so if something changes, it immediately synchronizes accordingly. Here is the code. Feel free to update me if you find errors, I use it to synchronize my web servers.
Enjoy,
////// This is the sync pair class definition
class SyncPair
{
private SyncToy.SyncEngineConfig l_ConfStream;
private SyncToy.SyncEngine l_SyncToy;
private System.IO.FileSystemWatcher l_leftwatcher;
private System.IO.FileSystemWatcher l_rightwatcher;
public SyncPair(SyncToy.SyncEngineConfig ConfStream)
{
//Create the SyncToy Instance
l_ConfStream = ConfStream;
l_SyncToy = new SyncToy.SyncEngine(l_ConfStream);
//Set up left side watcher
l_leftwatcher = new FileSystemWatcher();
l_leftwatcher.Path = l_SyncToy.LeftDir;
l_leftwatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
l_leftwatcher.Created += new FileSystemEventHandler(OnChanged);
//Set up right side watcher
l_rightwatcher = new FileSystemWatcher();
l_rightwatcher.Path = l_SyncToy.RightDir;
l_rightwatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite
| NotifyFilters.FileName | NotifyFilters.DirectoryName;
l_rightwatcher.Created += new FileSystemEventHandler(OnChanged);
//Start watching for changes
l_leftwatcher.EnableRaisingEvents = true;
l_rightwatcher.EnableRaisingEvents = true;
}
// Define the event handlers.
private void OnChanged(object source, System.IO.FileSystemEventArgs e)
{
if (e.ChangeType.ToString() == "Created")
{
//stop monitoring
l_leftwatcher.EnableRaisingEvents = false;
l_rightwatcher.EnableRaisingEvents = false;
//synchronize
l_SyncToy.Preview();
l_SyncToy.Sync();
//restart monitoring
l_leftwatcher.EnableRaisingEvents = true;
l_rightwatcher.EnableRaisingEvents = true;
}
}
}
////// This code goes in the service class
public partial class AutoSyncMain : ServiceBase
{
static SyncPair sp;
public AutoSyncMain()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
try
{
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter db = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
System.IO.StreamReader sr = new StreamReader(Properties.Settings.Default.ConfigurationSettingsFile);
do
if (sr.BaseStream.CanRead)
sp = new SyncPair((SyncToy.SyncEngineConfig)db.Deserialize(sr.BaseStream));
while (sr.BaseStream.Position < sr.BaseStream.Length);
sr.Close();
}
catch (Exception ex)
{
EventLog.WriteEntry("AutoSyncWatcher", ex.Message, EventLogEntryType.Error);
}
}
}
Juan Tordoya
|
|
|
|
|
One of the downfalls of SyncTo to me is its lack of support for FTP. oes anybody think there may be a way to make the engine support FTP or is it just file folder based .
|
|
|
|
|
Now that we know how to read a SyncToy config file in a variable of type "SyncToy.SyncEngineConfig" and pass it to the SyncToyEngine, does anyone know how to write a variable of type "SyncToy.SyncEngineConfig" to a config file? I can dynamically create the SyncToyEngine config and I pass it to the SyncToyEngine, but I'd like to write this config to a file and then run the SyncToy.exe -R"FolderPairName" to get the GUI interface rather than the console.
I see to read the SyncToy config file, we "deserialize" the input stream, but I can't figure out to "serialize" the output string to get it into the correct format to write to a file.
Any ideas? Thanks!
-Curt
|
|
|
|
|
This is really fairly simple to do. Google .net serialization and you'll find quite a few examples. You more or less reverse the process.
Psuedo-code:
Dim sc As SyncToy.SyncEngineConfig = your config
Dim db As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
db.Serialize(sc, filePath)
Serialization is really quite interesting. You can use it on any class you mark as <serializable()> (all sub classes also need that too).
|
|
|
|
|
This is what I figured I would need to do, my code is almost identical to your psudeo code:
Dim sc As SyncToy.SyncEngineConfig
Dim db As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
' set sc's properties here
db.Serialize(sc, "c:\test.dat")
When I try to compile, I get the error "Value of type 'SyncToy.SyncEngineConfig' cannot be converted to 'System.IO.Stream'" I see when we read fromthe config file, we use CTYPE to convert it to the SyncToy.SyncEngineConfig type. I can't figure out how to convert it into a serializable type.
Any ideas?
-Curt
|
|
|
|
|
Curti,
That is because Serialize() is looking for a stream as input, not just a string representing the file path. There are many types of streams (file of course is one of them). Try the following (I haven't tested this):
Signature of Serialize(): Public Sub Serialize(ByVal serializationStream As System.IO.Stream, ByVal graph As Object)
db.Serialize(New System.IO.FileStream("C:\dat.dat", IO.FileMode.Create), sc)
|
|
|
|
|
You're the best, that did just the thing I needed. Thanks so much for your help!
-Curt
|
|
|
|
|
'How to write folder pairs to the config
Dim sc As New SyncToy.SyncEngineConfig
sc.LeftDir = "c:\log"
sc.RightDir = "d:\logs"
sc.Name = "my logs"
sc.SyncMode = SyncMode.Synchronize
Dim db As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
db.Serialize(New System.IO.FileStream(getDataPath() & "\filecloner.config", IO.FileMode.Create), sc)
|
|
|
|
|
When I run the program, it will only process the first folder pair in my SyncToy configuration. I have been studying the SyncEngine object model and can not see any way to iterate through the various folder pairs. If I run the 'real' SyncToy, then examine the log file that it produces, it is doing a Preview() and a Sync() for each pair.
I'm stumped at this point, it works great for one folder pair, but not for the whole configuration.
|
|
|
|
|
Your comment leads me to believe that all folder pairs are stored in one config file. I hadn't tested that out. If that is the case, Copy the file to another location after you create each folder pair. This way, the file will only have one file pair in the config. You can also step through the code to check this when it deserializes the file. If you can seperate the config into multiple files, then just call the exe with each file name. Otherwise, if you see that all configs are in one file, then maybe you can tweak the code a bit to add a for each loop...
|
|
|
|
|
I added a While ... Loop around the configuration reading/sync section and now it will sync all pairs.
While sr.BaseStream.CanRead<br />
<br />
sc = CType(db.Deserialize(sr.BaseStream), SyncToy.SyncEngineConfig)<br />
se1 = New SyncToy.SyncEngine(sc)<br />
Console.WriteLine("Analyzing...")<br />
se1.Preview()<br />
Console.WriteLine("Done analyzing.")<br />
<br />
Console.WriteLine("")<br />
Console.WriteLine("")<br />
<br />
se1.Sync()<br />
System.Diagnostics.EventLog.WriteEntry("SyncToy", se1.StatSummary, EventLogEntryType.Information)<br />
<br />
End While
|
|
|
|
|
Hi Shaggy:
That is an excellent solution, Thanks!!
Allen W. Todd
AllenWTodd@msn.com
|
|
|
|
|
Nice. Thanks for your contribution!
|
|
|
|