重複の可能性:
ファイルを別のパスにコピーする方法は?
コードの実行が開始されたら、あるフォルダーから別のフォルダーに画像をコピーする必要があります。実行を開始するたびに、これが発生するはずです。
重複の可能性:
ファイルを別のパスにコピーする方法は?
コードの実行が開始されたら、あるフォルダーから別のフォルダーに画像をコピーする必要があります。実行を開始するたびに、これが発生するはずです。
Public void CopyFiles(string sourcePath,string destinationPath)
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
foreach(string file in files)
{
System.IO.File.Copy(sourcePath,destinationPath);
}
}
私の考えは、次のコードを使用することです-
public void CopyFiles(string sourcePath, string destinationPath)
{
string[] files = System.IO.Directory.GetFiles(sourcePath);
Parallel.ForEach(files, file =>
{
System.IO.File.Copy(file, System.IO.Path.Combine(destinationPath, System.IO.Path.GetFileName(file)));
});
}
File.Copyメソッドを使用して、ある場所から別の場所にファイルをコピーできます。