I ve found the Stack Overflow question describing how to backup the IIS Metabase in C# here, and I have been successful at getting that to work using the code referenced here. However, I am having difficulty restoring those backups (or indeed any backups created manually in IIS) using C# code.
Does anyone know how to do this, or even if it can be done? I haven t been able to find any examples of this on the web, unlike the backup itself.
I have tried the following code, but receive the error Exception has been thrown by the target of an invocation
using (DirectoryEntry localhostIIS = new DirectoryEntry("IIS://LocalHost"))
{
localhostIIS.Invoke("Restore", new object[] { string.Empty, 0, 0});
}
Now while I m sure that I m calling the method with the wrong name and/or object structure, I haven t been able to find the correct way of calling it anywhere....
Can anybody please point me in the right direction?