Advertisement

10.03.2007 at 04:02PM PDT, ID: 22870868
[x]
Attachment Details

Trying to Create virtual Directory using c# and getting exception

Asked by trnsfrmrsr in C# Programming Language, .NET

Tags: directory, virtual, create

I'm trying to create a virtual directory using the code:

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

namespace VirtualDirectoryCreator
{
    class Program
    {
        static void Main(string[] args)
        {
            string name = "mytestdir";
           
            //welcome of sorts
            DirectoryEntry rootDir = new DirectoryEntry("IIS://Localhost/W3SVC/1/Root");
            DirectoryEntry vDir = rootDir.Children.Add(name, "IIsWebVirtualDir");
            rootDir.RefreshCache();

           

            vDir.Properties["AccessRead"].Insert(0, true);
            vDir.Properties["Path"].Insert(0, "c:\temp");
            vDir.CommitChanges();
            rootDir.CommitChanges();

            // Create a Application
            vDir.Invoke("AppCreate", true);
            vDir.CommitChanges();
                   
        }
    }
}

however, evertime i try to run the program an exception gets thrown at the line

DirectoryEntry vDir = rootDir.Children.Add(name, "IIsWebVirtualDir");

Any idea on what could be causing this exception? Start Free Trial
 
Loading Advertisement...
 
[+][-]10.03.2007 at 04:07PM PDT, ID: 20010751

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:09PM PDT, ID: 20010757

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:21PM PDT, ID: 20010801

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, .NET
Tags: directory, virtual, create
Sign Up Now!
Solution Provided By: surajguptha
Participating Experts: 2
Solution Grade: B
 
 
[+][-]10.03.2007 at 04:21PM PDT, ID: 20010804

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:22PM PDT, ID: 20010808

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:22PM PDT, ID: 20010809

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:23PM PDT, ID: 20010810

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:24PM PDT, ID: 20010815

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:25PM PDT, ID: 20010822

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 04:27PM PDT, ID: 20010826

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.03.2007 at 05:03PM PDT, ID: 20010980

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628