是否有 .NET 库或 API 来与/编辑 IIS 元数据库进行交互? [英] Is there a .NET Library or API to interact with/Edit the IIS Metabase?

查看:21
本文介绍了是否有 .NET 库或 API 来与/编辑 IIS 元数据库进行交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

...或者我是否坚持使用自己的XML 斩波"功能.我想创建一个小型任务托盘应用程序,以便我可以快速将虚拟目录重新指向我硬盘上的几个文件夹之一.

...or am I stuck rolling my own "XML chopping" functions. I'd like to create a small tasktray app so I can quickly re-point a Virual Directory to one of several of folders on my harddisk.

一点背景:

我的开发机器上有 3 个不同的代码库 svn 分支.

I have 3 different svn branches of our code base on my dev machine.

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

我们的应用程序与我安装的第 3 方 CMS 集成

Our app integrates with a 3rd party CMS which I've installed at

http://localhost/cms/

为了工作,我们的应用程序必须位于同一个根目录中.所以:

In order to work our app has to live at the same root directory. so:

http://localhost/app/

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

Depending on the branch I'm working on, I'm re-pointing the /app/ directory to one of the 3 paths listed above by going into IIS Manager. Just thought it'd be handy to have a quick-app to do it for me.

推荐答案

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

Ok...this isn't a tray app but you can run it from the command line. Just change the physical paths as necessary:

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 库或 API 来与/编辑 IIS 元数据库进行交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆