本文整理汇总了C#中System.Progress.UpdateInstall方法的典型用法代码示例。如果您正苦于以下问题:C# Progress.UpdateInstall方法的具体用法?C# Progress.UpdateInstall怎么用?C# Progress.UpdateInstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Progress
的用法示例。
在下文中一共展示了Progress.UpdateInstall方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyDirectoryAsync
public static Task CopyDirectoryAsync(string source, string destination, Progress progress) => Task.Run(() =>
{
progress.UpdateInstall(0);
var total = Directory.EnumerateFiles(source, "*", SearchOption.AllDirectories).Count();
var current = 0;
CopyDir(source, destination, progress, total, ref current);
});
示例2: CopyDir
// From http://stackoverflow.com/questions/677221/copy-folders-in-c-sharp-using-system-io
//
static void CopyDir(string source, string destination, Progress progress, int total, ref int current)
{
var src = new DirectoryInfo(source);
var dest = new DirectoryInfo(destination);
if (!dest.Exists)
{
dest.Create();
}
// Copy all files
var files = src.GetFiles();
foreach (var file in files)
{
file.CopyTo(Path.Combine(dest.FullName, file.Name), true);
current++;
progress.UpdateInstall((int)Math.Round((double)current / total * 100.0));
}
// Process subdirectories
var dirs = src.GetDirectories();
foreach (var dir in dirs)
{
// Get destination directory
var destinationDir = Path.Combine(dest.FullName, dir.Name);
// Call CopyDirectory() recursively.
CopyDir(dir.FullName, destinationDir, progress, total, ref current);
}
}