I'm going to copy multiple files from one directory to another but the problem i face is that "my code copy only one file from one directory to another" .
actually i'm going to make the clone of File explorer with specified directory . I've tried to copy multiple files from one directory to another but my code work on only coping one file from multiple files.
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK){
string dess = path_textBox.Text;
File.Copy(ofd.FileName, dess + "\\" + ofd.SafeFileName, true);}
I expect the output is "Coping multiple files from one directory to another in c# window form"
Copy Multiple Files
string strDestinationFolder = @"D:\Barcode Copied";
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
foreach (string fileName in ofd.FileNames)
{
System.IO.File.Copy(fileName, strDestinationFolder + @"\" + System.IO.Path.GetFileName(fileName));
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.