PC Review


Reply
Thread Tools Rate Thread

How to Create a Virtual Directory using C#?

 
 
Smitha Nataraj
Guest
Posts: n/a
 
      28th Sep 2005
Hello,

I need to create a Virtual Directory in C#.

Pls let me know if you have any hints regarding this..

Thanks,
Smitha


 
Reply With Quote
 
 
 
 
Gnanaprakash Rathinam
Guest
Posts: n/a
 
      28th Sep 2005
What do u exactly mean by Virtual directory?

"Smitha Nataraj" <(E-Mail Removed)> wrote in message
news:dhdal5$8vu$(E-Mail Removed)...
> Hello,
>
> I need to create a Virtual Directory in C#.
>
> Pls let me know if you have any hints regarding this..
>
> Thanks,
> Smitha
>
>



 
Reply With Quote
 
Smitha Nataraj
Guest
Posts: n/a
 
      28th Sep 2005

I need to create a Virtual directory in IIS i.e. I need to create a web
application on the IIS server from my .NET application.

This can be done using DirectoryServices in .NET. But I am facing some
problems. The directory entry is done but I cannot see it in IIS manager nor
does the application exist. But, if we try to create it again with the same
name, it says already exists.

Pls let me know if you have any hint...

Thanks!
Smitha

"Gnanaprakash Rathinam" <(E-Mail Removed)> wrote in message
news:j6r_e.37$(E-Mail Removed)...
> What do u exactly mean by Virtual directory?
>
> "Smitha Nataraj" <(E-Mail Removed)> wrote in message
> news:dhdal5$8vu$(E-Mail Removed)...
> > Hello,
> >
> > I need to create a Virtual Directory in C#.
> >
> > Pls let me know if you have any hints regarding this..
> >
> > Thanks,
> > Smitha
> >
> >

>
>



 
Reply With Quote
 
Marc Jennings
Guest
Posts: n/a
 
      28th Sep 2005
I used this in the past...

>/// <summary>
>/// Create a new Virtual Directory within IIS
>/// </summary>
>/// <param name="ServerId">The ID of the Server within IIS</param>
>/// <param name="VirtualDirName">IIS Name of the new Virtual Directory</param>
>/// <param name="Path">Physical Path to the new Virtual Directory</param>
>/// <param name="AccessScript"></param>
>/// <param name="CreatePhysicalFolder">Create the folder on the file system</param>
>public static bool CreateNewVirtualDirectory(int ServerId, string VirtualDirName, string Path, bool AccessScript, bool CreatePhysicalFolder)
>{
> DirectoryEntry Parent = new DirectoryEntry(@"IIS://localhost/W3SVC/" + ServerId.ToString() + "/Root");
> DirectoryEntry NewVirtualDir;
> NewVirtualDir = Parent.Children.Add(VirtualDirName, "IIsWebVirtualDir");
> NewVirtualDir.Properties["Path"][0] = Path;
> NewVirtualDir.Properties["AccessScript"][0] = AccessScript;
> NewVirtualDir.Properties["AppFriendlyName"][0] = VirtualDirName;
> NewVirtualDir.Properties["AppPoolId"][0] = "DefaultAppPool";
> NewVirtualDir.Properties["AppRoot"][0] = "/LM/W3SVC/" + ServerId.ToString() + "/Root/" + VirtualDirName;
> NewVirtualDir.Properties["AppIsolated"][0] = 2;
> NewVirtualDir.CommitChanges();
> if(CreatePhysicalFolder)
> {
> if(!Directory.Exists(Path))
> {
> Directory.CreateDirectory(Path);
> return true;
> }
> }
> else
> {
> return true;
> }
> return true;
>}


(Error checking / catching has been stripped from this example...)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
to create a virtual directory pol Windows XP General 0 11th Nov 2008 07:07 AM
Web Setup project - create virtual directory & point to another location in directory structure kplkumar@gmail.com Microsoft C# .NET 0 12th Apr 2006 06:26 PM
Cannot create Virtual Directory in IIS from asp.net =?Utf-8?B?U3RlcGhhbmU=?= Microsoft ASP .NET 1 9th Dec 2004 01:05 PM
vcdeploy : error VCD0035: Failed to create the file system directory for the virtual directory. Access is denied. Dominic Microsoft VC .NET 0 17th Jun 2004 01:27 AM
How to create a new Virtual Directory? qiuji Microsoft ASP .NET 0 12th Aug 2003 08:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:36 AM.