コード例 #1
0
 private void ConversionBW_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (CreationPB.InvokeRequired)
     {
         CreationPB.Invoke(new MethodInvoker(delegate
         {
             CreationPB.Value = e.ProgressPercentage;
         }));
     }
 }
コード例 #2
0
        private void ConversionBW_DoWork(object sender, DoWorkEventArgs e)
        {
            if (CreationPB.InvokeRequired)
            {
                CreationPB.Invoke(new MethodInvoker(delegate
                {
                    CreationPB.Maximum = directory.GetFiles().Count();
                    CreationPB.Value   = 0;
                }));
            }

            foreach (FileInfo file in directory.GetFiles())
            {
                if (Extensions.Contains(file.Extension.ToLower()))
                {
                    string dir = file.Name.Substring(0, file.Name.Length - 4);

                    if (directory.GetDirectories().Contains(new DirectoryInfo(dir)))
                    {
                        Directory.Delete(dir);
                    }

                    directory.CreateSubdirectory(dir);
                }

                if (CreationPB.InvokeRequired)
                {
                    CreationPB.Invoke(new MethodInvoker(delegate
                    {
                        CreationPB.Value += 1;
                    }));
                }

                ConversionBW.ReportProgress(CreationPB.Value);
            }
        }