I recently asked a question about finding directories in C # .
Program logic
- List all directories in a line or several lines.
- Try copying the file using the line.
- If this fails, continue to the next line,
- If you can find the file:
- Copy
- go to next record in text file
Final result
If he finds it on the 4th line, he will not try the next 15 lines.
Code snippet
if (checkBox2.Checked)
{
string[] file_names = File.ReadAllLines(@"c:\dact.txt");
string path1 = @"I:\pa\test\";
string path2 = @"I:\pa\test2\";
string path3 = @"I:\pa\test3\";
string path4 = @"I:\pa\test4\";
string full = (string.Concat(path1, file_names, ".txt"));
foreach (string file_name in file_names)
if (System.IO.File.Exists(full))
{
foreach (string file in file_names)
System.IO.File.Copy(file,
@"C:\" +
textBox1.Text +
@"\\OC\" +
file_name + ".txt");
}
}
The above code does not contain the ability to write files with an error, I'm not sure how to do this.
, :
1.
2.
3. , ,
4. " ", .
5. - 19- .
user222427