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

Virtual Folder: How to create and populate?

Hi!

I would like to create a virtual folder (which I want to mount) and
populate managing his content by a DLL or something like that in VB.NET
(2.0).

How can I acomplish this?
Thanks to all!
sid.
Nov 23 '05 #1
2 2668
Roughly translated from
http://msdn.microsoft.com/library/de...db1142a456.asp

Imports System
Imports System.IO
Imports System.DirectoryServices
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports System.Collections

Namespace System_DirectoryServices_DirectoryEnTry_ConfigIIS
Class Program
Shared Sub Main(ByVal args() As String)

...
CreateSite("IIS://Localhost/W3SVC", "555", "MySite",
"D:\\Inetpub\\Wwwroot")

...
SetSingleProperty("IIS://Localhost/W3SVC/555",
"ServerBindings", ":8080:")

...
CreateVDir("IIS://Localhost/W3SVC/1/Root", "MyVDir",
"D:\\Inetpub\\Wwwroot")

...
End Sub

...
Shared Sub CreateSite(ByVal metabasePath As String, ByVal siteID
As String, ByVal siteName As String, ByVal physicalPath As String)
' metabasePath is of the form "IIS://<servername>/<service>"
' for example "IIS://localhost/W3SVC"
' siteID is of the form "<number>", for example "555"
' siteName is of the form "<name>", for example, "My New Site"
' physicalPath is of the form "<drive>:\<path>", for example,
"C:\Inetpub\Wwwroot"
Console.WriteLine("\nCreating site {0}/{1}, mapping the Root
application to {2}:",
metabasePath, siteID, physicalPath)

Try
Dim service As DirectoryEnTry = New
DirectoryEnTry(metabasePath)
Dim className As String = service.SchemaClassName.ToString()
If className.EndsWith("Service") Then
Dim sites As DirectoryEntries = service.Children
Dim NewSite As DirectoryEnTry =
sites.Add(siteID,(className.Replace("Service","Ser ver")))
NewSite.Properties("ServerComment")(0) = siteName
NewSite.CommitChanges()

Dim NewRoot As DirectoryEnTry
NewRoot = NewSite.Children.Add("Root", "IIsWebVirtualDir")
NewRoot.Properties("Path")(0) = physicalPath
NewRoot.Properties("AccessScript")(0) = True
NewRoot.CommitChanges()

Console.WriteLine(" Done. Your site will not start until you
set the ServerBindings or SecureBindings property.")
Else
Console.WriteLine(" Failed. A site can only be created in a
service node.")
End If
Catch ex As Exception
Console.WriteLine("Failed in CreateSite with the following
exception: \n{0}", ex.Message)
End Try
End Sub

...
Shared Sub SetSingleProperty(ByVal metabasePath As String, ByVal
propertyName As String, ByVal NewValue As Object)
' metabasePath is of the form "IIS://<servername>/<path>"
' for example "IIS://localhost/W3SVC/1"
' propertyName is of the form "<propertyName>", for example
"ServerBindings"
' value is of the form "<intStringOrBool>", for example, ":80:"
Console.WriteLine("\nSetting single property at {0}/{1} to {2}
({3}):",
metabasePath, propertyName, NewValue,
NewValue.GetType().ToString())

Try
Dim path As DirectoryEnTry = New DirectoryEnTry(metabasePath)
Dim propValues As PropertyValueCollection =
path.Properties(propertyName)
Dim oldType As String = propValues.Value.GetType().ToString()
Dim NewType As String = NewValue.GetType().ToString()
Console.WriteLine(" Old value of {0} is {1} ({2})",
propertyName, propValues.Value, oldType)
If NewType = oldType Then
path.Properties(propertyName)(0) = NewValue
path.CommitChanges()
Console.WriteLine("Done")
Else
Console.WriteLine(" Failed in SetSingleProperty; type of
new value does not match property")
End If
Catch ex As Exception
If "HRESULT 0x80005006" = ex.Message Then
Console.WriteLine(" Property {0} does not exist at {1}",
propertyName, metabasePath)
Else
Console.WriteLine("Failed in SetSingleProperty with the
following exception: \n{0}", ex.Message)
End If
End Try
End Sub

...
Shared Sub CreateVDir(ByVal metabasePath As String, ByVal vDirName
As String, ByVal physicalPath As String)
' metabasePath is of the form
"IIS://<servername>/<service>/<siteID>/Root[/<vdir>]"
' for example "IIS://localhost/W3SVC/1/Root"
' vDirName is of the form "<name>", for example, "MyNewVDir"
' physicalPath is of the form "<drive>:\<path>", for example,
"C:\Inetpub\Wwwroot"
Console.WriteLine("\nCreating virtual directory {0}/{1}, mapping
the Root application to {2}:",
metabasePath, vDirName, physicalPath)

Try
Dim site As DirectoryEnTry = New DirectoryEnTry(metabasePath)
Dim className As String = site.SchemaClassName.ToString()
If (className.EndsWith("Server"))
||(className.EndsWith("VirtualDir")) Then
Dim vdirs As DirectoryEntries = site.Children
Dim NewVDir As DirectoryEnTry =
vdirs.Add(vDirName,(className.Replace("Service","V irtualDir")))
NewVDir.Properties("Path")(0) = physicalPath
NewVDir.Properties("AccessScript")(0) = True
' These properties are necessary for an application to be
created.
NewVDir.Properties("AppFriendlyName")(0) = vDirName
NewVDir.Properties("AppIsolated")(0) = "1"
NewVDir.Properties("AppRoot")(0) = "/LM" +
metabasePath.Substring(metabasePath.IndexOf("/", ("IIS://".Length)))

NewVDir.CommitChanges()

Console.WriteLine(" Done.")
Else
Console.WriteLine(" Failed. A virtual directory can only be
created in a site or virtual directory node.")
End If
Catch ex As Exception
Console.WriteLine("Failed in CreateVDir with the following
exception: \n{0}", ex.Message)
End Try
End Sub

...
End Class
End Namespace
"§iD`" <mi****@ngi.it> wrote in message
news:43***********************@reader3.news.tin.it :
Hi!

I would like to create a virtual folder (which I want to mount) and
populate managing his content by a DLL or something like that in VB.NET
(2.0).

How can I acomplish this?
Thanks to all!
sid.


Nov 23 '05 #2
scorpion53061 disse, il 13/11/2005 3.08:
Roughly translated from
http://msdn.microsoft.com/library/de...db1142a456.asp

(cut)

Excelly I mean a File System Virtual Directory, not an IIS one...
Nov 23 '05 #3

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

Similar topics

1
by: Juan Daniel Caicedo | last post by:
I create an user session with ASP in a Virtual Folder. When the ASP try to delete a subfolder in the same virtual folder app, FSO delete the folder but they clean the session and clean all...
2
by: Julie J. | last post by:
How do you create a virtual folder in VS.NET? It is simple enough to create a physical folder, but I want to create virtual folders like I was able to do in VS 6. Anyone know how? -JJ-
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
0
by: Drew Berkemeyer | last post by:
Hello, I've been trying all day to create an installer for an ASP.NET application that has a sub-app running in a virtual directory under the primary app. Specifically, I have an ASP.NET...
1
by: §iD` | last post by:
Hi, I would like to create a file system virtual directory which should be accessible by Explorer and by application from the standard path (ex. c:\virtual_directory). I would like to be able to...
2
by: Kavitha | last post by:
Hi , Can any one tel me how to create a virtual drive in C#( similar to Gmail Virtual drive).Also tell me what interfaces could be used to create the same. Thanks in Advance Kavitha
4
by: Luc The Perverse | last post by:
Hi - I have very little C# programming experience. I am making a software product which calls for an interface almost identical to Windows Explorer - and I wondered if mounting a "virtual drive"...
1
by: Thomas W | last post by:
I want to create a virtual filesystem based on a relational database. It might run as a server on a different machine, but it has to be available like a normal filesystem, either shared using...
0
by: vibsapril | last post by:
I have an application like blog system where I have to provide the space for every new blog. I have seen on aeonity.com that when a new blog is created, a new virtual folder is created dynamically. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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.