Welcome to HostingForumz.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

Cannot create a Virtual Directory using System.DirectorySe..

 
   Web Hosting Problem Solving Community! (Home) -> IIS RSS
Related Topics:
cannot create new virtual directory - Each time I try to create a new virtual directory on IIS4, an error meesage tells me there is already a virtual directory with the same name. It then tries to rename the new one by adding a '2' to the end. But there is not a

How to create a Virtual Directory II6 from ASP - Hi, I need to create some IIS Virtual from ASP. Where can I find some about this topic ? Thanks in advance Stan

Using adsutil to create a virtual directory - Hi, Im creating a virtual directory in local IIS with and I can set its path, but I can't find any on how to set all the other options, like the Execute and Can someone point me at a web site..

Please Help! How to create IIS Virtual directory programma.. - Hello, I am using Visual C++ 6.0. In my I have to create in the Web Site - virtual directory and also I want to be able to change of this vitrual directory (All process of creation virtual ..

Can I create virtual directory by script remotely? - As title. Any idea? Thanks, Alan
Next:  IIS: FTP question  
Author Message
fredfrog22

External


Since: Oct 05, 2006
Posts: 1



(Msg. 1) Posted: Thu Oct 05, 2006 3:05 am
Post subject: Cannot create a Virtual Directory using System.DirectoryServices on Windows Vista RC1
Archived from groups: microsoft>public>inetserver>iis (more info?)

Hi,

The following is an extract from a C# console application that creates
a Virtual Directory on IIS 5 or 6.

This code works on XP, Windows 2003 Server, Windows 2000.

It does not work on Windows Vista Release Candidate 1 (IIS 7).

The below line

pcProps[VDPROP_PATH].Value = strPath;

throws the exception "Path not found".

Note that the user running the exe has administrator rights on the
machine.

Also, this may be a related issue:

The Microsoft VB script C:\Inetpub\Adminscripts\mkwebdir.vbs no longer
works on Windows Vista RC1 when logged in as an administrator.

Interestingly, I have found that other sample code downloaded from the
Internet that creates virtual directories does not work on Vista
either.

Thanks for your help.

+++++++++++

Code extract:
DirectoryEntry deRoot = new DirectoryEntry(IIS_DIR);

if (null != deRoot)

try
{
// check to see if this Virtual Directory already exists
m_deVirtualDir = deRoot.Children.Add(m_strVirtualDir,
IIS_SCHEMA_VIRTUAL_DIR);
}
catch
{
try
{
String strDir = IIS_DIR + "/" + m_strVirtualDir;
m_deVirtualDir = new DirectoryEntry(IIS_DIR + "/" +
m_strVirtualDir);
}
catch
{
}
}

if (null != m_deVirtualDir)
{
// commit the changes so far!
deRoot.CommitChanges();
m_deVirtualDir.CommitChanges();

// now we need to set up some properties of the new virtual
// directory
PropertyCollection pcProps = m_deVirtualDir.Properties;


// set the Path to the Virtual Directory
string strPath = m_strIISPath + "\\" + m_strVirtualDir;

// exception generated here
pcProps[VDPROP_PATH].Value = strPath;

etc etc

 >> Stay informed about: Cannot create a Virtual Directory using System.DirectorySe.. 
Back to top
Login to vote
steve23

External


Since: Oct 16, 2004
Posts: 126



(Msg. 2) Posted: Sat Oct 07, 2006 5:49 pm
Post subject: Re: Cannot create a Virtual Directory using System.DirectoryServices on Windows Vista RC1 [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

You can use Microsoft.Web.Administration or Microsoft.Web.management
namespaces that are new for IIS7 to do this vs. ADSI. One thing if you are
trying to use legacy scripts is make sure the Vista RC1 client has the IIS6
Management Compatibility is installed.

'Here is an article I did with some code samples for IIS7
http://weblogs.asp.net/steveschofield/archive/2006/09/10/test-post.aspx

Steve Schofield
Microsoft MVP - IIS



<fredfrog22 DeleteThis @hotmail.com> wrote in message
news:1160042753.270423.127560@m73g2000cwd.googlegroups.com...
> Hi,
>
> The following is an extract from a C# console application that creates
> a Virtual Directory on IIS 5 or 6.
>
> This code works on XP, Windows 2003 Server, Windows 2000.
>
> It does not work on Windows Vista Release Candidate 1 (IIS 7).
>
> The below line
>
> pcProps[VDPROP_PATH].Value = strPath;
>
> throws the exception "Path not found".
>
> Note that the user running the exe has administrator rights on the
> machine.
>
> Also, this may be a related issue:
>
> The Microsoft VB script C:\Inetpub\Adminscripts\mkwebdir.vbs no longer
> works on Windows Vista RC1 when logged in as an administrator.
>
> Interestingly, I have found that other sample code downloaded from the
> Internet that creates virtual directories does not work on Vista
> either.
>
> Thanks for your help.
>
> +++++++++++
>
> Code extract:
> DirectoryEntry deRoot = new DirectoryEntry(IIS_DIR);
>
> if (null != deRoot)
>
> try
> {
> // check to see if this Virtual Directory already exists
> m_deVirtualDir = deRoot.Children.Add(m_strVirtualDir,
> IIS_SCHEMA_VIRTUAL_DIR);
> }
> catch
> {
> try
> {
> String strDir = IIS_DIR + "/" + m_strVirtualDir;
> m_deVirtualDir = new DirectoryEntry(IIS_DIR + "/" +
> m_strVirtualDir);
> }
> catch
> {
> }
> }
>
> if (null != m_deVirtualDir)
> {
> // commit the changes so far!
> deRoot.CommitChanges();
> m_deVirtualDir.CommitChanges();
>
> // now we need to set up some properties of the new virtual
> // directory
> PropertyCollection pcProps = m_deVirtualDir.Properties;
>
>
> // set the Path to the Virtual Directory
> string strPath = m_strIISPath + "\\" + m_strVirtualDir;
>
> // exception generated here
> pcProps[VDPROP_PATH].Value = strPath;
>
> etc etc
>

 >> Stay informed about: Cannot create a Virtual Directory using System.DirectorySe.. 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> IIS All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]