问题
We don't want file syncing between our handheld device and the PC.
The handheld device puts certain (SQL CE database) files in the \My Documents folder on the handheld. These are, in particular, the files we don't want synced to the PC.
I first added "sdf" (and "SDF" just to be sure) to the "ExcludeExts" registry key. That didn't help. I then changed the "FileSyncPath" and "NoSubfolderIn" registry keys from the "My Documents" folder to the "profiles" folder:
private void UpdateRegistry()
{
RegistryKey key =
Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows CE
Services");
if (key != null)
{
key.SetValue("ExcludeExts", "lnk,tmp,cdb,mdb,sdf,SDF",
RegistryValueKind.String);
key.SetValue("FileSyncPath", "\\profiles",
RegistryValueKind.String);
key.SetValue("NoSubfolderIn", "\\profiles\\",
RegistryValueKind.String);
}
}
The profiles folder has nothing but another folder in it, which should be ignored due to the "NoSubfolderIn" registry key:
The changes have been written to the Registry on the device:
...but I still get the .SDF file from \My Documents synced over to the PC:
Why? Would changing where the .SDF file is stored on the device be the solution (IOW, move it from "My Documents", which the file syncing seems to want to use no matter what)? Or, do I need to also update additional Windows CE Services registery folders? Oddly enough, there are three on the device, plus a "Windows CE Tools" folder:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows CE Services <= It has one registry key, "DeviceFriendlyName"
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services <= shown in the scream shot above; it has several (7) registry keys
HKEY_LOCAL_MACHINE\Windows CE Tools <= It has one registry key, "Platform"
HKEY_LOCAL_MACHINE\Windows CE Services <= it's empty
Are these registry keys just "teases"? Am I missing something here?
UPDATE
I added these entries, to put the same values in the other two places on the handheld's registry where there is a "Windows CE Services" folder:
RegistryKey keyLocalWCES =
Registry.LocalMachine.CreateSubKey(@"Windows CE Services");
if (null != keyLocalWCES)
{
keyLocalWCES.SetValue("GuestOnly", 00000001
RegistryValueKind.DWord);
keyLocalWCES.SetValue("ExcludeExts", "lnk,tmp,cdb,mdb,sdf,SDF"
RegistryValueKind.String);
keyLocalWCES.SetValue("FileSyncPath", "\\profiles",
RegistryValueKind.String);
keyLocalWCES.SetValue("NoSubfolderIn", "\\profiles\\",
RegistryValueKind.String);
}
RegistryKey keyCurrentUser
Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Windows CE
Services");
if (null != keyCurrentUser)
{
keyCurrentUser.SetValue("GuestOnly", 00000001
RegistryValueKind.DWord);
keyCurrentUser.SetValue("ExcludeExts"
"lnk,tmp,cdb,mdb,sdf,SDF", RegistryValueKind.String);
keyCurrentUser.SetValue("FileSyncPath", "\\profiles",
RegistryValueKind.String);
keyCurrentUser.SetValue("NoSubfolderIn", "\\profiles\\",
RegistryValueKind.String);
}
...and I still have the file being synced! Heavens to Murgatroid, what's a cat to do when his cheese keeps getting moved this-a-way?!?
UPDATE 2
This is how I solved the dilemma: I save the files in question (*.SDF files in the current release, *.sqlite files in the next release) to a different location than what is set as the "FileSyncPath" value. Specifically, in my case, I changed the "FileSyncPath" back to what it had always been "My Documents" but changed where I was saving the files that I did not want to be synced, to an innocuous-looking little folder named "profiles." It seems to work pretty well, now: nothing is being synced to the PC. ActiveStync is showing an err msg, but I think that it's just made that it wasn't able to steal the files, and is simply "blowing off steam."
Or, it might be safer when refactoring to keep saving the data where you always have, but simply change the values of the "FileSyncPath" (and perhaps the "NoSubfolderIn" although it's probably unnecessary) key registry values to something other than where the data is being stored (or to a location other than where the files you don't want to be synced exist).
来源:https://stackoverflow.com/questions/28350937/why-does-the-handheld-device-ignore-the-filesyncpath-registry-keys-value