Exemplo n.º 1
0
        private bool InitLocalFiles()
        {
            long dealtSize = 0;

            foreach (FH2File fh2File in this.fileIndex)
            {
                FH2File localfile = clone(fh2File);
                string  fileName  = fh2File.name;
                string  filePath  = Path.Combine("..", "..", fh2File.target, fh2File.name);
                localfile.Client(filePath, rootFolder, this.webRoot);
                dealtSize += fh2File.size;
                double Progress = dealtSize / this.totalSize;
                localFiles.Add(localfile);
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += new DoWorkEventHandler(
                    delegate(object o, DoWorkEventArgs args)
                {
                    report(Progress);
                });
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
                    delegate(object o, RunWorkerCompletedEventArgs args)
                {
                    worker.Dispose();
                });
                worker.RunWorkerAsync();
            }
            return(true);
        }
        private bool InitLocalFiles(object sender)
        {
            this.localFiles.Clear();
            long          dealtSize = 0;
            DirectoryInfo folder    = new DirectoryInfo(Application.StartupPath);

            folder = folder.Parent.Parent;
            foreach (FH2File fh2File in this.fileIndex)
            {
                if (sender != this.parent.CurrentOwner)
                {
                    Console.WriteLine("Cancel this MD5Check.");
                    return(false);
                }
                FH2File localfile = fh2File.Clone();
                string  fileName  = fh2File.name;
                string  filePath  = Path.Combine(Path.Combine(folder.FullName, fh2File.target), fh2File.name);
                localfile.Client(filePath, rootFolder);
                dealtSize += fh2File.size;
                double Progress = (double)dealtSize / (double)this.totalSize;
                localFiles.Add(localfile);
                Report(Progress);
            }
            return(true);
        }