コード例 #1
0
        private void CopyWorkThread(object param)
        {
            CopyMeta copyMeta = (CopyMeta)param;

            File.Copy(copyMeta.FullName, copyMeta.DestnationFile, copyMeta.Overwrite);
            Console.WriteLine("[Thread {0}]:copying...{1} to {2}", Thread.CurrentThread.ManagedThreadId, copyMeta.FullName, copyMeta.DestnationFile);
        }
コード例 #2
0
        private void copyToDest(IList <FileInfo> files, string toPath)
        {
            if (files.Count == 0)
            {
                return;
            }

            foreach (var fi in files)
            {
                try
                {
                    string tempYearMonth = fileHelper.GetRevisedMonth(fi);
                    string destFile      = Path.Combine(toPath, tempYearMonth, fi.Name);
                    //File.Copy(fi.FullName, destFile, true);

                    CopyMeta copyMeta = new CopyMeta {
                        FullName = fi.FullName, DestnationFile = destFile, Overwrite = true
                    };
                    Thread newThread = new Thread(new ParameterizedThreadStart(CopyWorkThread));
                    newThread.Start(copyMeta);

                    //ProgressMark.ProgressedFiles++;
                }
                catch (DirectoryNotFoundException ex)
                {
                    break;
                }
                catch (FileNotFoundException e)
                {
                    break;
                }
            }
        }