...或者我是否坚持使用我自己的<!>“XML切断<!>”;功能。我想创建一个小型任务栏应用程序,这样我就可以快速将虚拟目录重新指向我硬盘上的几个文件夹中的一个。

背景:

我的dev机器上有3个不同的svn分支。

Current Production Branch    ( C:\Projects\....\branches\Prod\ )
Next Release Canidate Branch ( C:\Projects\....\branches\RCX\ )
Trunk                        ( C:\Projects\....\trunk\ )

我们的应用程序与我在

安装的第三方CMS集成
http://localhost/cms/

为了工作,我们的应用必须住在同一个根目录。这样:

http://localhost/app/

根据我正在处理的分支,我通过进入IIS管理器将/app/目录重新指向上面列出的3个路径之一。只是觉得有一个快速应用程序为我做这件事很方便。

有帮助吗?

解决方案

好的...这不是托盘应用程序,但您可以从命令行运行它。只需根据需要更改物理路径:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;

namespace Swapper
{
  class Program
  {
    static void Main(string[] args)
    {
      using (DirectoryEntry appRoot = 
               new DirectoryEntry("IIS://Localhost/W3SVC/1/root/app"))
      {
        switch (args[0].ToLower())
        {
          case "prod":
            appRoot.Properties["Path"].Value = @"e:\app\prod";
            appRoot.CommitChanges();
            break;

          case "rcx":
            appRoot.Properties["Path"].Value = @"e:\app\rcx";
            appRoot.CommitChanges();
            break;

          case "trunk":
            appRoot.Properties["Path"].Value = @"e:\app\trunk";
            appRoot.CommitChanges();
            break;

          default:
            Console.WriteLine("Don't know");
            break;
        }
      }
    }
  }
}

然后按以下方式运行:

C:\>swapper prod
C:\>swapper rcx

其他提示

我没有用过这个我自己,所以我不是百分百肯定会解决你的问题。但是看看.NET中的System.DirectoryServices。它可以访问IIS。

DirectoryServices的MSDN帮助

那么,对于IIS 7,有一个.NET包装器可以通过.NET启用IIS管理。有关详细信息,请参阅此链接

http://learn.iis.net/ page.aspx / 165 /如何使用的-microsoftwebadministration /

对于以前版本的IIS(5或6),提供了ADSI和WMI接口,

http://msdn.microsoft.com/en-us/library /ms525885.aspx

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top