I found a stack overflow question that describes how to backup the IIS metabase in C # here , and I was successful in getting this to work using the code shown here . However, I am having difficulty restoring these backups (or even any manually created backups in IIS) using C # code.
Does anyone know how to do this, or even if it can be done? I could not find any examples of this on the Internet, unlike the backup itself.
I tried the following code, but I get the error "Exception was selected as the target of the call"
using (DirectoryEntry localhostIIS = new DirectoryEntry("IIS://LocalHost"))
{
localhostIIS.Invoke("Restore", new object[] { string.Empty, 0, 0});
}
Now that I'm sure that I am calling a method with the wrong name and / or structure of the object, I could not find the correct way to call it anywhere ....
Can someone point me in the right direction?
source
share