我已经编写了一个程序来与远程服务器同步文件。但我无法找到一种方法来通过服务器的用户名密码&。我已经提供了下面的代码。它在两个本地目录之间工作。我在这里使用了微软同步框架。但即使在搜索解决方案的天数之后,我也无法修改它以与远程服务器一起使用。有人可以让我知道在这里包括凭据的方式。在此先感谢与远程服务器同步文件
string RemoteserverPath = "https://xxx.xxx.xxx.xxx.com/login/login.jsp";
string ClientPath = "E:/test";
try
{
FileSyncOptions options = FileSyncOptions.ExplicitDetectChanges |
FileSyncOptions.RecycleDeletedFiles | FileSyncOptions.RecyclePreviousFileOnUpdates | FileSyncOptions.RecycleConflictLoserFiles;
FileSyncScopeFilter filter = new FileSyncScopeFilter();
filter.FileNameExcludes.Add("*.lnk"); // Exclude all *.lnk files
DetectChangesOnFileSystemReplica(
RemoteserverPath, filter, options);
DetectChangesOnFileSystemReplica(
ClientPath, filter, options);
// Sync in both directions
SyncFileSystemReplicasOneWay(RemoteserverPath, ClientPath, null, options);
SyncFileSystemReplicasOneWay(ClientPath, RemoteserverPath, null, options);
MessageBox.Show("Done");
}
catch (Exception e1)
{
MessageBox.Show("\nException from File Sync Provider:\n" + e1.ToString());
}
如果服务器支持,您可以尝试在URL字符串中指定凭据。 – AgentFire
你真的想将文件发送到登录页面,还是我误解你的代码? –
@AgentFire,你好我改变了我的编码如下。但它会抛出一个错误消息,称为“标识符预期”。 string replica1RootPath =“https://data-set1.xxx.xxx.xxxxx.com”,“xxx”,“xxxx”; –