C#中创建iis 虚拟目录遇到难题(未处理COMException 当文件已存在时,无法创建该文件。异常来自HRESULT:0x800700B7)请大大来帮忙诊断下
偶做安装程序,需要建立一个iis的虚拟目录,开始运行没问题,但是多次运行后就出现标题的报错,偶是C#新兵 请各位大大帮忙解决下,真心感谢
以下是源代码
System.DirectoryServices.DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT");
DirectoryEntry tbEntry = root.Children.Add(virtualDirName,root.SchemaClassName);
tbEntry.Properties["Path"][0] = physicalPath;
tbEntry.Invoke("AppCreate", true);
tbEntry.Properties["AccessRead"][0] = true;
tbEntry.Properties["AccessExecute"][0] = false;
tbEntry.Properties["ContentIndexed"][0] = true;
tbEntry.Properties["DefaultDoc"][0] = "default.aspx";
tbEntry.Properties["AppFriendlyName"][0] = strbm;
tbEntry.Properties["AccessScript"][0] = true;
tbEntry.Properties["DontLog"][0] = true;
tbEntry.Properties["AuthFlags"][0] = 0;
tbEntry.Properties["AppIsolated"][0] = 2;
tbEntry.Properties["AccessWrite"][0] = false;//写入权限
tbEntry.Properties["EnableDirBrowsing"][0] = false; //目录浏览
tbEntry.CommitChanges();
MessageBox.Show("创建虚拟目录成功!","信息提示");