473,386 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to Create a Virtual Directory using C#?

Hello,

I need to create a Virtual Directory in C#.

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

Thanks,
Smitha
Nov 17 '05 #1
3 2138
What do u exactly mean by Virtual directory?

"Smitha Nataraj" <sm************@in.bosch.com> wrote in message
news:dh**********@ns2.fe.internet.bosch.com...
Hello,

I need to create a Virtual Directory in C#.

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

Thanks,
Smitha

Nov 17 '05 #2

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" <gn*******************@oracle.com> wrote in message
news:j6**************@news.oracle.com...
What do u exactly mean by Virtual directory?

"Smitha Nataraj" <sm************@in.bosch.com> wrote in message
news:dh**********@ns2.fe.internet.bosch.com...
Hello,

I need to create a Virtual Directory in C#.

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

Thanks,
Smitha


Nov 17 '05 #3
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...)
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
0
by: No Spam | last post by:
After looking all the ways to progrrammatically create a new FTP Server & Virtual Directory, I have come to see that the code below is the cleanest. Here is my basic issue. When I run this code, I...
0
by: CM | last post by:
Hi there: I have a web project which can be open and run without problem. I didn't open the web application for a period and during which I didn't modified any IIS items, but now I cannot open any...
4
by: CM | last post by:
Hi there: I have a web project which can be open and run without problem. I didn't open the web application for a period and during which I didn't modified any IIS items, but now I cannot open any...
2
by: Mickey | last post by:
When I try to create a new web application in VS Studio .NET 2003 at a simple default location eg: http://localhost/WebApplication1 I get the following error: Visual Studio .NET cannot create or...
1
by: chenggf | last post by:
How to create the tow virtual directory in one Install program with Microsoft.Net ?
2
by: Siegfried Heintze | last post by:
I ran Internet Services Manager to create a virtual directory whose physical path was C:\InetPub\wwwroot\SIGNITEK_PRIVATE. Since this notebook is not exposed on the network, I gave the virtual...
1
by: Stephane | last post by:
Hi, I'm trying to create a virtual directory dynamically in my web site using ASP.NET. I received this error: System.Runtime.InteropServices.COMException (0x800700B7): Cannot create a file...
4
by: Mark | last post by:
Hello, I'm trying to install an ASP.Net project using the command line (SDK tools & perhaps IIS Admin scripts?) Does anyone know of an automatic, command-line-driven way, to creat the ASP.Net...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.