I trying to write a basic progress feature when copying files from a remote location within my console application
Basically there are 13148 within a set of folders. However my application doesn’t seem to update itself when running when the files are being copy over.
I just post the code just in case it's something stupid. I will go into more detail if require
Thanks
Tom
This is just the code for the progress bit since the rest of the program is fine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.IO;
using System.Threading;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
RegistryKey checkreg2 = Registry.CurrentUser.OpenSubKey(@"software\\knowledgeplanning");
decimal check3 = Convert.ToDecimal(checkreg2.GetValue("count"));
RegistryKey amendreg = Registry.CurrentUser.CreateSubKey(@"software\\knowledgeplanning");
decimal check4 = Convert.ToDecimal(checkreg2.GetValue("count2"));
decimal cal = (100 / check3) * check4;
while (check4 < check3)
{
Thread.Sleep(1000);
Console.WriteLine(Convert.ToInt32(cal) + "%");
//cal = 0;
try
{
amendreg.DeleteValue("count2");
}
catch { }
try
{
decimal grandtotal = 0;
DirectoryInfo file = new System.IO.DirectoryInfo(@"c:\\Knowledge Planning");
decimal file3 = (file.GetFiles().Length);
grandtotal = 0 + file3;
//Console.WriteLine(file3);
string[] dirs = Directory.GetDirectories(@"c:\\Knowledge Planning");
foreach (string dir in dirs)
{
DirectoryInfo file2 = new DirectoryInfo(dir);
decimal total = (file2.GetFiles().Length);
decimal subtotal = grandtotal = total + grandtotal;
decimal finalgrandtotal = grandtotal;
amendreg.SetValue("count2", Convert.ToString(grandtotal));
}
}
catch
{ }
}
try
{
amendreg.DeleteValue("count2");
}
catch { }
}
}
}

New Topic/Question
Reply




MultiQuote




|