Problem while creating virtual directory programatically.

Problem while creating virtual directory programatically.

am 07.04.2008 15:58:10 von Balaram Barange

This is a multi-part message in MIME format.

------=_NextPart_000_0026_01C898E5.83BA5A60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi All,

I am trying to create a virtual directory programatically using the =
following code, if works fine, but when I try to create with the same =
name again, I get exception. If I use diffrent names for virtual =
directory no issues, and I am actually deleting that virtual directory =
before creating it again.

here is the code to create virtual directory:
Dim webDir as string =3D "myWeb"
vRoot =3D GetObject("IIS://LocalHost/W3svc/1/Root") '<- "sometimes =
exception here"
Dim vdir =3D vRoot.Create("IIsWebVirtualDir", webDir ) '<- "sometimes =
exception here"
vdir.Path =3D somepath + webFolder ' this is a valid path provided=20
vdir.DefaultDoc =3D "default.aspx"
vdir.AccessSSL =3D True
vdir.SetInfo()
vdir.AppCreate(True)


Can some body help me with this. I am getting random errors in this =
code, when I provide the same virtual directory name,=20
sometimes it gives
1. "Object reference not set to instance of..."=20
2. "Cannot create a file when that file already exists(Exception from =
HRESULT:0x800700B7)"

at statement: vRoot.Create("IIsWebVirtualDir", websiteVirtualDir)

Is there something I am missing here, Any help will be appreciated.=20

Thanks,
Bala


------=_NextPart_000_0026_01C898E5.83BA5A60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-1">




Hi All,

 

I am trying to create a  virtual =
directory=20
programatically using the following code, if works fine, but when I try =
to=20
create with the same name again, I get exception. If I use diffrent =
names=20
for virtual directory no issues, and I am actually deleting that =
virtual=20
directory before creating it again.

 

here is the code to create virtual=20
directory:


face=3DVerdana>Dim webDir=20
as string =3D "myWeb"
vRoot =3D =
GetObject("IIS://LocalHost/W3svc/1/Root") '<-=20
"sometimes exception here"
Dim vdir =3D =
vRoot.Create("IIsWebVirtualDir", webDir=20
) '<- "sometimes exception here"
vdir.Path =3D somepath + =
webFolder ' this=20
is a valid path provided
vdir.DefaultDoc =3D =
"default.aspx"
vdir.AccessSSL=20
=
True
vdir.SetInfo()
vdir.AppCreate(True)

T> size=3D2>

Can some body help me with =
this.=20
I am getting random errors in this code, when I =
provide the=20
same virtual directory name,

sometimes it gives

1. "Object reference not set to =
instance of..."=20

2. "Cannot create a file when that =
file already=20
exists(Exception from HRESULT:0x800700B7)"

 

at statement: size=3D2> face=3DVerdana size=3D2>vRoot.Create("IIsWebVirtualDir",=20
websiteVirtualDir)

 

Is there something I am missing =
here, Any=20
help will be appreciated.

 

Thanks,

Bala

 

 


------=_NextPart_000_0026_01C898E5.83BA5A60--