-
Notifications
You must be signed in to change notification settings - Fork 26
Standard File System Services
Thong Nguyen edited this page May 27, 2013
·
1 revision
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.
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);