473,473 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VS 2008 C# to create a IIS virtual directory

1 New Member
Good morning. Could someone please assist me in find the correct way to do this. I have tried a couple methods but it seems VS 2008 does not support all the directives that previous versions did, or maybe they were just renamed. Below is the code I have but cannot seem to get it to run in 2008. I keep getting error "The type or namespace name 'Directory' could not be found (are you missing a using directive or an assembly reference?" Any help would be appreciated. Thanks-Adam
[code]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{

}

private void label2_Click(object sender, EventArgs e)
{

}

private void button1_Click(object sender, System.EventArgs e)
{
string strSchema = "";
string strRootSubPath = "";
if (radioButton1.Checked)
{
strSchema = "IIsWebVirtualDir";
strRootSubPath = "/W3SVC/1/Root";
}
if (radioButton2.Checked)
{
strSchema = "IIsFtpVirtualDir";
strRootSubPath = "/MSFTPSVC/1/Root";
}
if (strSchema == "")
{
strSchema = "IIsWebVirtualDir";
strRootSubPath = "/W3SVC/1/Root";
}
DirectoryEntry deRoot = new DirectoryEntry("IIS://" + txtServer.Text + strRootSubPath);
try
{
deRoot.RefreshCache();
DirectoryEntry deNewVDir = deRoot.Children.Add(txtVDirName.Text, strSchema);
deNewVDir.Properties["Path"].Insert(0, txtVDir.Text);
deNewVDir.CommitChanges();
deRoot.CommitChanges();
// Create a Application
if (strSchema == "IIsWebVirtualDir")
deNewVDir.Invoke("AppCreate", true);
// Save Changes
deNewVDir.CommitChanges();
deRoot.CommitChanges();
deNewVDir.Close();
deRoot.Close();
lblStatus.Text = "Virtual Directory " + txtVDirName.Text + "(" + txtVDir.Text + ") has been created";
}
catch (Exception ex)
{
lblStatus.Text = "Error: " + ex.Message;
}

}
}
}
{/CODE]
Jan 3 '08 #1
0 1171

Sign in to post your reply or Sign up for a free account.

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...
3
by: Smitha Nataraj | last post by:
Hello, I need to create a Virtual Directory in C#. Pls let me know if you have any hints regarding this.. Thanks, Smitha
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...
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...
1
by: kplkumar | last post by:
Hi I am new to this. I am trying to create a setup project to package our stuff and create an installer. This is what I want to do, I have a directory sructure in which we have our...
6
by: Lloyd Sheen | last post by:
Ok I copied a VS 2005 web site to another folder. Open my new VS 2008. Attempt to run. I get the following: Error 1 It is an error to use a section registered as...
3
by: =?Utf-8?B?U3RldmUgTGFGb3JnZQ==?= | last post by:
I have an intranet site and want to create a simple master page to be shared across all applications that are built for that site. I build my master page in c:\inetpub\wwwroot\Masters as...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.