Tech Off Thread

1 post

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

how to change my virtual directory's properties, and find its index

Back to Forum: Tech Off
  • User profile image

    I'm trying to write permission to my web directory resides on the host machine, do some work and then set write permission false. I find some code like the following but it doesn't work, and by the way I don't know hot to find index of my virtual directory. If I write for the variable "siteIndex", it doesn't work, too.


    using Microsoft.WindowsMediaServices.Interop;

    using System.Management;

    using interop_msxml;


    string strServerName = Server.Name;

    ConnectionOptions options = new ConnectionOptions();

    ManagementScope scope = new ManagementScope ("\\\\" + strServerName + "\\root\\MicrosoftIISV2", options);

    string wmiPath = "IIsWebDirectorySetting='W3SVC/" + siteIndex + "/root/" + path + "'";

    ManagementObject iisVDir = new ManagementObject(scope, new ManagementPath(wmiPath), null);

    iisVDir.SetPropertyValue("AccessWrite", true);


    //do some work

    iisVDir.SetPropertyValue("AccessWrite", false);

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.