Asked by:
Synchronizing file from "C:\folderName" to web server "http://localhost:80/Content/Files/"

Question
-
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; }
Monday, May 20, 2013 2:18 PM
All replies
-
the file sync provider doesnt support synching over http.Tuesday, May 21, 2013 11:28 AM
-
So what is alternative way then ? Please help !Tuesday, May 21, 2013 3:17 PM
-
You could try using Windows Shared Folders or write your own Provider.Wednesday, May 29, 2013 1:38 AM