Dear friends,
I want to synchronize folder/sub-folders/files from file system to web-server/local-server
My application is working fine as long as i give source and destination path as local directories("C:\Source", "C:\ Destination" , but when
i change it source from "C:\Source" to "web server" using WebRequest method i get exception of "URI
formats are not supported"
WebRequest serverAdress = WebRequest.Create("http://localhost:80/Content/Files/") as HttpWebRequest;
serverAdress.Method = "POST";
serverAdress.Credentials = new NetworkCredential("http://localhost:80/", "Anonymous");
startSync(serverAdress.RequestUri.ToString(), thisUser);
And here is my synchronization function
private bool Synchronize(String source, String destination)
{
SyncOperationStatistics syncOperationStatistics;
//Assign Unique Guids to the source and destination replicas
sourceReplicaID = GetReplicaID(Path.Combine(source, "ReplicaID"));
destinationReplicaID = GetReplicaID(Path.Combine(destination, "ReplicaID"));
//Create the source Sync Provider, attach the path and assign the ReplicaID
sourceProvider = new FileSyncProvider(sourceReplicaID, source);
//Create the destination Sync Provider, attach the path and assign the ReplicaID
destinationProvider = new FileSyncProvider(destinationReplicaID, destination);
SyncOrchestrator synchronizationAgent = new SyncOrchestrator();
synchronizationAgent.LocalProvider = sourceProvider;
synchronizationAgent.RemoteProvider = destinationProvider;
try
{
//Start the synchronization process
syncOperationStatistics = synchronizationAgent.Synchronize();
//Assign synchronization statistics to the lstStatistics control
//listBox1.Items.Add("Download Applied: " + syncOperationStatistics.DownloadChangesApplied.ToString());
//listBox1.Items.Add("Download Failed: " + syncOperationStatistics.DownloadChangesFailed.ToString());
//listBox1.Items.Add("Download Total: " + syncOperationStatistics.DownloadChangesTotal.ToString());
//listBox1.Items.Add("Upload Total: " + syncOperationStatistics.UploadChangesApplied.ToString());
//listBox1.Items.Add("Upload Total: " + syncOperationStatistics.UploadChangesFailed.ToString());
//listBox1.Items.Add("Upload Total: " + syncOperationStatistics.UploadChangesTotal.ToString());
}
catch (Microsoft.Synchronization.SyncException se)
{
MessageBox.Show(se.Message, "Sync Files - Error");
return false;
}
finally
{
// Release resources once done
if (sourceProvider != null)
sourceProvider.Dispose();
if (destinationProvider != null)
destinationProvider.Dispose();
}
return true;
}