我们不希望在我们的手持设备和 PC 之间进行文件同步。
手持设备将某些(SQL CE 数据库)文件放在手持设备的 \My Documents 文件夹中。这些尤其是我们不希望同步到 PC 的文件。
我首先将“sdf”(和“SDF”只是为了确定)添加到“ExcludeExts”注册表项。那没有帮助。然后,我将“我的文档”文件夹中的“FileSyncPath”和“NoSubfolderIn”注册表项更改为“配置文件”文件夹:
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);
}
}
配置文件文件夹中只有另一个文件夹,由于“NoSubfolderIn”注册表项,应忽略该文件夹:
更改已写入设备上的注册表:
...但我仍然将 .SDF 文件从 \My Documents 同步到 PC:
为什么?更改 .SDF 文件在设备上的存储位置是否是解决方案(IOW,将其从“我的文档”中移动,文件同步似乎无论如何都想使用它)?或者,我是否还需要更新其他 Windows CE 服务注册文件夹?奇怪的是,设备上有三个,外加一个“Windows CE Tools”文件夹:
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
这些注册表项只是“戏弄”吗?我在这里错过了什么吗?
更新
我添加了这些条目,以便将相同的值放在掌上电脑注册表的其他两个位置,其中有一个“Windows CE 服务”文件夹:
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);
}
...我仍然有正在同步的文件!天哪,Murgatroid,当他的奶酪一直这样移动时,猫该怎么办?!?
更新 2
这就是我解决困境的方法:我将有问题的文件(当前版本中的 *.SDF 文件,下一版本中的 *.sqlite 文件)保存到与设置为“FileSyncPath”值不同的位置。具体来说,就我而言,我将“FileSyncPath”改回了它一直以来的“我的文档”,但将我不想同步的文件的保存位置更改为一个名为“profiles”的看似无害的小文件夹。” 现在看来工作得很好:没有任何东西同步到 PC。ActiveStync 显示一个错误消息,但我认为它只是因为它无法窃取文件,而只是“发泄”。
或者,在重构时将数据保存在您一直拥有的位置可能会更安全,但只需将“FileSyncPath”(也可能是“NoSubfolderIn”,尽管可能没有必要)键注册表值更改为数据所在位置以外的其他值正在存储(或存储到您不想同步的文件所在的位置以外的位置)。