473,407 Members | 2,306 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,407 software developers and data experts.

VS 2008 C# to create a IIS virtual directory

1
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 1169

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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.