简体   繁体   English

如何共享将图像从一个文件夹复制到另一个文件夹的过程

[英]how to share image copying from one folder to another folder Process in c#

When we are copying images in one folder to another folder, images are going to copy one by one, then it takes more time when thousands's of images are copying, Is there any Possibility to copy Multiple images at a time? 当我们将一个文件夹中的图像复制到另一个文件夹时,图像将被一张一张地复制,那么当复制成千上万张图像时,则需要花费更多的时间,是否有可能一次复制多张图像? "This is My code" “这是我的代码”

              int avilableCharts = 0;
              int unavialableCharts = 0;
              string chartid;
              int count = 0;
                StreamReader rd = new StreamReader(txtFileName.Text);
                StreamWriter tw = new StreamWriter("C:\\LogFiles\\SucessfullyMovedImages.txt");
                StreamWriter tw1 = new StreamWriter("C:\\LogFiles\\UnavailableImages.txt");
                DirectoryInfo dirinfo = new DirectoryInfo(txtSourceFolder.Text);
                FileInfo[] file = dirinfo.GetFiles("*.pdf");
                while (!rd.EndOfStream)
                {
                    chartid = rd.ReadLine() + ".pdf";
                    count = count + 1;
                    worker.ReportProgress(count);
                    string FName = string.Empty;                      
                    if (File.Exists(txtSourceFolder.Text + chartid))

                    {
                        File.Copy(txtSourceFolder.Text + chartid , txtDestinationFolder.Text +          chartid );
                        avilableCharts = avilableCharts + 1;
                        tw.WriteLine(chartid);                            
                    }
                    else
                    {
                        unavialableCharts = unavialableCharts + 1;
                        tw1.WriteLine(chartid);
                    }

                }
                tw.Close();
                tw1.Close();
                MessageBox.Show("Successfully Copied Images are :" + avilableCharts);
                MessageBox.Show("Total Unavilable Images are : " + unavialableCharts);    

use below code : 使用以下代码:

public class SimpleFileMove
 {
  static void Main()
   {
    string sourceFile = @"C:\Users\Public\public\test.txt";
    string destinationFile = @"C:\Users\Public\private\test.txt";

    // To move a file or folder to a new location:
    System.IO.File.Move(sourceFile, destinationFile);

    // To move an entire directory. To programmatically modify or combine
    // path strings, use the System.IO.Path class.
    System.IO.Directory.Move(@"C:\Users\Public\public\test\", @"C:\Users\Public\private");
}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# 将文件从一个文件夹复制到另一个文件夹的真实时间 - C# true time for copying files from one folder to another folder 仅当文件名是指定文本文件c中的文件名时,才将文件从一个文件夹复制到另一个文件夹 - copying files from one folder to another only if their file name is a in a specified text file c# 如何在C#中将文件从一个文件夹复制到另一个文件夹? - How to copy file from one folder to another in C#? 将文件从一个文件夹移动到另一进程正在使用的C#错误文件 - Move files from one folder to another C# Error File being used by another process 如何使用 SharpSsh 和 C# 将文件从一个文件夹移动到远程服务器上的另一个文件夹 - How to move a file from one folder to another folder on a remote server using SharpSsh and C# c#将文件从源文件夹复制到目标文件夹 - c# copying files from source folder to target folder 如何通过C#从共享文件夹读取文件? - How to read file from share folder by C#? 如何使用C#共享文件夹和添加权限 - How to share a folder and add permissions with C# 将文件夹从一个目录移动到另一个目录。 在C#中 - Moving a folder, from one directory to another. in c# C#将文件从一个文件夹复制到另一个文件夹而不重复 - C# to copy files from one folder to another without duplicates
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM