Progmatically create a Virtual Directory in .NET

This is a discussion on "Progmatically create a Virtual Directory in .NET" within the ASP.NET Forum section. This forum, and the thread "Progmatically create a Virtual Directory in .NET are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > ASP.NET Forum

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 28th, 2004, 17:42
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Progmatically create a Virtual Directory in .NET

Does anyone know how to progmatically create a new Virtual Directory, or web application root?

This is driving me nutz!

(I know you can do it in IIS, and front-page and other tools, but this has gotta be done in .NET!)
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work

  #2 (permalink)  
Old Aug 31st, 2004, 10:37
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
Create a Virtual Directory and Edit its Properties in IIS using C#

http://dotnetjunkies.com/WebLog/ramd...les/21777.aspx
  #3 (permalink)  
Old Aug 31st, 2004, 10:42
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
or:

Code: Select all
public static void CreateVDir(string sPhysicalPath, string sVirDirName)
{
System.DirectoryServices.DirectoryEntry oDE;
System.DirectoryServices.DirectoryEntries oDC;
System.DirectoryServices.DirectoryEntry oVirDir;
string sIISPath;

try
{
sIISPath = "IIS://" + _sHost + "/W3SVC/" + _sServer + "/Root";
oDE = new DirectoryEntry(sIISPath);
oDC = oDE.Children; 
oVirDir = oDC.Add(sVirDirName,oDE.SchemaClassName.ToString()); 
oVirDir.CommitChanges(); 

oVirDir.Properties["Path].Value = sPhysicalPath; 
oVirDir.Properties["AccessRead][0] = true;
oVirDir.Invoke("AppCreate",true); 
oVirDir.Properties["AppFriendlyName][0] = sVirDirName;

oVirDir.CommitChanges(); 
}
catch (Exception exc)
{
throw new Exception(exc.Message); 
}
}
  #4 (permalink)  
Old Aug 31st, 2004, 12:25
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Smokie..... you found the holy grail!

Thanks.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Closed Thread

Tags
progmatically, create, virtual, directory, net

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual Brochure bean_2k1 Flash & Multimedia Forum 2 Jun 19th, 2007 20:22
You want to create a what? Directory or other? newbieobiwan Website Planning 1 Jun 8th, 2007 20:41
Create Virtual Communities and Workshops lgroon Job Opportunities 0 Aug 2nd, 2005 12:13
Include Virtual on IIS jakenoble PHP Forum 3 Mar 8th, 2004 07:22
Virtual Tour.... courtjester Flash & Multimedia Forum 6 Dec 1st, 2003 15:33


All times are GMT. The time now is 21:03.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43