Hi, I want to copy all the video files from one directory (source folder) to another directory (destination folder) which i have already done. Code is given below.
Now i want to put some condition.
For Example, I want to read first the text file (videoID.txt)in which all the video ID's are given line by line. now i want to match each video id against the source video folder, if it matches then copy that video to destination folder otherwise don't copy. Please help me to insert this condition in this code. thanks
static void Main(string[] args)
{
string fileName;
string destFile;
string sourcePath = @"E:\Source";
string targetPath = @"E:\Destination";
// To copy all the files in one directory to another directory.
string[] files = System.IO.Directory.GetFiles(sourcePath);
// Copy the files and overwrite destination files if they already exist.
foreach (string s in files)
{
// Use static Path methods to extract only the file name from the path.
fileName = System.IO.Path.GetFileName(s);
destFile = System.IO.Path.Combine(targetPath, fileName);
System.IO.File.Copy(s, destFile, true);
}
}