473,385 Members | 1,930 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,385 software developers and data experts.

IIS management

Hi there.
How can i process the folders under the default web site and do "create
application" task on spesific ones in .net with c#? (i know the names of
them.)
Thanx.
Burak SARICA

Nov 16 '05 #1
4 4224
"Burak SARICA" <bu*********@bbbilisim.com> wrote in message
news:Ow**************@tk2msftngp13.phx.gbl...
Hi there.
How can i process the folders under the default web site and do "create
application" task on spesific ones in .net with c#? (i know the names of
them.)


Burak,

You can use this code to create an IIS application:

public enum IIsInProcessFlags { InProcess, OutOfProcess, Pooled }

public void CreateApplication(string path, string name, IIsInProcessFlags
flag) {
using (DirectoryEntry entry = new DirectoryEntry(path)) {
entry.Invoke("AppCreate2", new object[1] { (int)flag });
entry.Properties["AppFriendlyName"].Value = name;
entry.CommitChanges();
}
}
hth
andrew
Nov 16 '05 #2
Thanx andrew.
let's say there is a directory under default web site. (not an application)
can we handle this directory? And if we can, how can we make it an
application? (Or will i only execute your code? (I couldn't try your code))
"andrew lowe" <a n d r e w do t lowe [@] g e a c . com (Remove)> wrote in
message news:ul**************@TK2MSFTNGP15.phx.gbl...
"Burak SARICA" <bu*********@bbbilisim.com> wrote in message
news:Ow**************@tk2msftngp13.phx.gbl...
Hi there.
How can i process the folders under the default web site and do "create
application" task on spesific ones in .net with c#? (i know the names of them.)


Burak,

You can use this code to create an IIS application:

public enum IIsInProcessFlags { InProcess, OutOfProcess, Pooled }

public void CreateApplication(string path, string name, IIsInProcessFlags
flag) {
using (DirectoryEntry entry = new DirectoryEntry(path)) {
entry.Invoke("AppCreate2", new object[1] { (int)flag });
entry.Properties["AppFriendlyName"].Value = name;
entry.CommitChanges();
}
}
hth
andrew

Nov 16 '05 #3

"Burak SARICA" <bu*********@bbbilisim.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
Thanx andrew.
let's say there is a directory under default web site. (not an application) can we handle this directory? And if we can, how can we make it an
application? (Or will i only execute your code? (I couldn't try your

code))

Burak,

Sure you can do it. To get my code to work you have to add a reference to
the System.DirectoryServices assembly, and then add a using statement to the
top of your class file:

using System.DirectoryServices;

The path variable in the method i posted points to an adsi path, not a file
system path. Note to create an iis application you must first ensure that
the IIS metabase contains an IIsWebDirectory entry for your phsyical
directory.

Try the following code:

{
CreateWebDirectory(RootAdsiPath, "YourFolderName");
CreateApplication(RootAdsiPath + "/YourFolderName", "Your friendly
application name", IIsInProcessFlags.Pooled);
}

public static string RootAdsiPath {
get { return "IIS://" + Environment.MachineName + "/W3SVC/1/Root"; }
}

public void CreateApplication(string path, string name, IIsInProcessFlags
flag) {
using (DirectoryEntry entry = new DirectoryEntry(path)) {
entry.Invoke("AppCreate2", new object[1] { (int)flag });
entry.Properties["AppFriendlyName"].Value = name;
entry.CommitChanges();
}
}

public void CreateWebDirectory(string parentPath, string name) {
if (EntryExists(parentPath + "/" + name))
return;
using (DirectoryEntry entry = new DirectoryEntry(parentPath)) {
DirectoryEntry newEntry = (DirectoryEntry)entry.Invoke("Create", new
object[2] { "IIsWebDirectory", name });
newEntry.CommitChanges();
}
}

public bool EntryExists(string path) {
try {
using (DirectoryEntry entry = new DirectoryEntry(path)) {
return entry.Guid != Guid.Empty;
}
} catch {
return false;
}
}

hth
andrew
Nov 16 '05 #4
Thanx very much. That's absolutely what i need.

Burak SARICA

"andrew lowe" <a n d r e w do t lowe [@] g e a c . com (Remove)>, iletide
şunu yazdı news:uQ**************@TK2MSFTNGP11.phx.gbl...

"Burak SARICA" <bu*********@bbbilisim.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
Thanx andrew.
let's say there is a directory under default web site. (not an application)
can we handle this directory? And if we can, how can we make it an
application? (Or will i only execute your code? (I couldn't try your

code))

Burak,

Sure you can do it. To get my code to work you have to add a reference to
the System.DirectoryServices assembly, and then add a using statement to

the top of your class file:

using System.DirectoryServices;

The path variable in the method i posted points to an adsi path, not a file system path. Note to create an iis application you must first ensure that
the IIS metabase contains an IIsWebDirectory entry for your phsyical
directory.

Try the following code:

{
CreateWebDirectory(RootAdsiPath, "YourFolderName");
CreateApplication(RootAdsiPath + "/YourFolderName", "Your friendly
application name", IIsInProcessFlags.Pooled);
}

public static string RootAdsiPath {
get { return "IIS://" + Environment.MachineName + "/W3SVC/1/Root"; }
}

public void CreateApplication(string path, string name, IIsInProcessFlags
flag) {
using (DirectoryEntry entry = new DirectoryEntry(path)) {
entry.Invoke("AppCreate2", new object[1] { (int)flag });
entry.Properties["AppFriendlyName"].Value = name;
entry.CommitChanges();
}
}

public void CreateWebDirectory(string parentPath, string name) {
if (EntryExists(parentPath + "/" + name))
return;
using (DirectoryEntry entry = new DirectoryEntry(parentPath)) {
DirectoryEntry newEntry = (DirectoryEntry)entry.Invoke("Create", new object[2] { "IIsWebDirectory", name });
newEntry.CommitChanges();
}
}

public bool EntryExists(string path) {
try {
using (DirectoryEntry entry = new DirectoryEntry(path)) {
return entry.Guid != Guid.Empty;
}
} catch {
return false;
}
}

hth
andrew

Nov 16 '05 #5

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

Similar topics

0
by: Certified PM | last post by:
I am looking for as many additional resources as possible. Please post or email additional resources as it will be greatly appreciated. An excellent book to check out is Software/Firmware...
0
by: Scott Abel | last post by:
For immediate release: The Rockley Group Content Management Workshop Series Coming to Atlanta, Seattle, Vancouver, Chicago, Washington, DC, Toronto, and Research Triangle Park Learn more:...
2
by: Paul Gronka | last post by:
I've got a VB.NET windows application (written in VS .NET 2003) that makes a call to WMI for retrieving the MAC Address from the client's PC. It works on 4 out of the 5 PC's tested so far. All...
1
by: PaulThomas | last post by:
I am using VS.Net 2000 and C# trying to access the System.Management namespace in a Web Application -but- after: using System; using System.Management; I get: The type or namespace name...
1
by: andrewcw | last post by:
I have used System.Management in the past to extract and walk thru drives & check their type. I can also do it with COM's FileSystemObject. Here I am trying to just use the Management Object...
5
by: PCC | last post by:
I am using the Exception Managment Application Block on Windows Server 2003 Enterprise and .NET v1.1. If I use the block with an ASP.NET web wervice or in a web application I get the following...
7
by: scorpion53061 | last post by:
I get the following error with the class below it when installing on a NT/98/Me machine. Any suggestions would be helpful. Kind of in a bind. Suspect the issue revolves ...
1
by: lcifers | last post by:
I have an application that uses the following code to return the default printer: Dim moReturn As Management.ManagementObjectCollection Dim moSearch As Management.ManagementObjectSearcher Dim...
0
by: gaojihuiyuan | last post by:
SAN Database Management Discounted IP SAN solutions. Switch to SAN, get offer details. http://www.healthhuman.com.cn/Database-Management.htm Database Management Courses and Schools Gain new...
2
by: karthi84 | last post by:
Hi Experts, i have created a web application which has an option to edit the web config file from the web page. when i create an installer for this project using web setup project in VS2008 and...
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:
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.