I have a list (list1) with the file names:
C:\\Work\\Server1\\CSRegWeb\\Transform\\Faq.xslt
C:\\Work\\Server1\\CSRegWeb\\Content\\Axxess.xml
C:\\Work\\Server1\\CSRegWeb\\kleenex.aspx
C:\\Work\\Server1\\CSRegWeb\\Content\\dell.xml
I need to copy these files to another server (with the same folder structure), which is called server2. So the folder locations are:
C:\\Work\\Server2\\CSRegWeb\\Transform\\Faq.xslt
C:\\Work\\Server2\\CSRegWeb\\Content\\Axxess.xml
C:\\Work\\Server2\\CSRegWeb\\kleenex.aspx
C:\\Work\\Server2\\CSRegWeb\\Content\\dell.xml
I need to copy over the files (which can be copy or overwrite).
(For now they are server1 & server2, the server names can change).
Any help would be appreciated.
Here is the code I have:
DESTINATION_PROJECT_ROOT = "C:\\Work\\Server2"
projectName = "CSRegWeb"
string dest = DESTINATION_PROJECT_ROOT + "\\" + projectName + "\\" ;
foreach (FileInfo k in List1)
{
foreach (FileInfo j in List2)
{
if (k.Name == j.Name && k.Directory.Name == j.Directory.Name)
{
File.Copy(k.FullName, dest , true);
break;
}
}
}
This only replaces the modified files.
I don’t think you can access it that way. Try it this way instead:
EDIT
Or if you’re storing it in web.config, try this: