Answer the question
In order to leave comments, you need to log in
How to copy selected folders C#?
You need to copy folders with files in them.
For example, there is a function:
void perebor_updates(string begin_dir, string end_dir)
{
DirectoryInfo dir_inf = new DirectoryInfo(begin_dir);
foreach (DirectoryInfo dir in dir_inf.GetDirectories())
{
if (Directory.Exists(end_dir + "\\" + dir.Name) != true)
{
Directory.CreateDirectory(end_dir + "\\" + dir.Name);
}
perebor_updates(dir.FullName, end_dir + "\\" + dir.Name);
}
foreach (string file in Directory.GetFiles(begin_dir))
{
string filik = file.Substring(file.LastIndexOf('\\'), file.Length - file.LastIndexOf('\\'));
File.Copy(file, end_dir + "\\" + filik, true);
}
}
foreach (DirectoryInfo dir in dir_inf.GetDirectories())
Answer the question
In order to leave comments, you need to log in
On input IEnumerable or IEnumerable. Then:
void perebor_updates(IEnumerable<DirectoryInfo> dirs)
{
foreach(var dir in dirs)
...
}
void perebor_updates(IEnumerable<string> dirNames)
{
foreach(var name in dirNames)
{
var dir = new DirectoryInfo(name);
...
{
...
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question