Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » ASP 3.0




 Page 1 of 1 [ 5 posts ] 



Author Message
 Post subject: How 2 Create the Virtual Directory Programatically?
 Post Posted: Sun Nov 22, 2009 10:01 pm 
Offline

Joined: Sat Feb 21, 2009 2:15 pm
Posts: 62
Hi,

could any onw post da code 2 create a virtual directory programatically?

I m havinn a Folder "Projects" in c:\inetpub\wwwroot

I would lke to create a Virutual directory under dis folder

Any Help Would be Appritiated

_________________
The average woman would rather have beauty than brains, because the average man can see better than he can think.


Top 
 Post subject: Re: How 2 Create the Virtual Directory Programatically?
 Post Posted: Sun Nov 22, 2009 10:01 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Hi,
Code:
Using System.DirectoryServices;
private void btnCreateDirectory_Click(object sender, EventArgs e)
{
          string strSchema = "IIsWebVirtualDir";
          string strRootSubPath = "/W3SVC/1/Root" ;

           // you can specify any server name , "localhost" is for example
           DirectoryEntry deRoot =
                        new DirectoryEntry("IIS://" + "localhost" + strRootSubPath);
         try
        {
                 deRoot.RefreshCache();
                 DirectoryEntry deNewVDir =
                                    deRoot.Children.Add("Name of Virtual Directory", strSchema);

                 deNewVDir.Properties["Path"].Insert(0, "Path for Virtual Directory");
                 deNewVDir.CommitChanges();
                 deRoot.CommitChanges();

                // Create a Application
                if (strSchema == "IIsWebVirtualDir")
                           deNewVDir.Invoke("AppCreate", true);
                // Save Changes
                           deNewVDir.CommitChanges();
               
                deRoot.CommitChanges();
                deNewVDir.Close();
                deRoot.Close();
                lblResult.Text = "Virtual Directory "
                                   + ("Name of Virtual Directory"+ "(" + "Path for Virtual
                                             Directory" + ") has  been created";
       }
      catch (Exception ex)
     {
                lblResult.Text = ex.Message;
      }
}



OR

http://www.c-sharpcorner.com/UploadFile ... lDirs.aspx


Top 
 Post subject: Re: How 2 Create the Virtual Directory Programatically?
 Post Posted: Sun Nov 22, 2009 10:01 pm 
Offline

Joined: Sat Feb 21, 2009 2:15 pm
Posts: 62
Hi

Thanks 4 ur rply

This code is would create the Virtual Directory at iis rootlevel
(c:\inetpub\wwwroot)

In my case i would like to create a virtual directory unda folder(i.e. c:\inetpub\wwwroot\Projects)

could u pls post da code 2 create virtual directory under
some folder inside wwwroot??

_________________
The average woman would rather have beauty than brains, because the average man can see better than he can think.


Top 
 Post subject: Re: How 2 Create the Virtual Directory Programatically?
 Post Posted: Sun Nov 22, 2009 10:02 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
Good Work done . Keep it up.


Thanks,


Top 
 Post subject: Re: How 2 Create the Virtual Directory Programatically?
 Post Posted: Sun Nov 22, 2009 10:02 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Hi,

deRoot.Children.Add("Name of Virtual Directory", strSchema);

deNewVDir.Properties["Path"].Insert(0, "Path for Virtual Directory");

chk the above line and also..

U can chanfe path of C://Inetpub/www

run-->inetmgr-->propteries-->Dir tab.


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 5 posts ] 




Board index » Server Side Development » ASP 3.0


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron