You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thong Nguyen edited this page May 27, 2013
·
1 revision
Standard File System Services
Platform.VirtualFileSystem comes with some standard services based on the Platform.ITask. ITask based services can run in the current thread, a background thread and can be monitored for progress via the ITask.Progress.ValueChanged event.
FileTransferService
Copies a file from one location to another. The destination does not have to belong to the same file system. The service uses a hash specified by FileTransferServiceType.HashAlgorithmName to check if the contents of file needs to be transferred. Once a file is transferred, the service can be instructed to validate that the transfer was successful (FileTransferServiceType.VerifyIntegrity).
var src = FileSystemManager.Default.ResolveFile("http://www.github.com");
var des = FileSystemManager.Default.ResolveFile("C:/temp/index.html");
var service = src.GetService<IFileTransferService>(new FileTransferServiceType(des));
service.Progress.ValueChanged += (sender, args) => Console.WriteLine("Progress: {0}%", Convert.ToDouble(args.NewValue) / Convert.ToDouble((service.Progress.MaximumValue)) * 100);
service.Start();
service.WaitForAnyTaskState(TaskState.Finished);