//创建一个虚拟目录
DirectoryEntry dirRoot = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
DirectoryEntries dirs = dirRoot.Children;
DirectoryEntry virtualDir = dirs.Add("VirtualChange", dirRoot.SchemaClassName);
object[] objs = new object[] { true };
virtualDir.Invoke("AppCreate", objs);
virtualDir.Properties["AppFriendlyName"][0] = "VirtualChange";
virtualDir.Properties["Path"].Value = "C:\\VirtualChange";
virtualDir.CommitChanges();
//启动aspnet_iis.exe程序
string fileName = Environment.GetEnvironmentVariable("windir") + @"\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe";
ProcessStartInfo startInfo = new ProcessStartInfo(fileName);
//处理目录路径
string path = virtualDir.Path.ToUpper();
int index = path.IndexOf("W3SVC");
path = path.Remove(0, index);
//启动aspnet_iis.exe程序,刷新教本映射
startInfo.Arguments = "-s " + path;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = false;
startInfo.CreateNoWindow = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
string errors = process.StandardError.ReadToEnd();
if (errors != string.Empty)
throw new Exception(errors);
Console.WriteLine(process.StandardOutput.ReadToEnd());
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有