DirectoryEntry and CopyTo function

DirectoryEntry and CopyTo function

Post by Mi » Sat, 05 Jul 2003 19:47:17



Hi

I am struggling to make a Web site/Web Directory copy work. I am using
the System.DirectoryServices to connect to my localhost machine.

There I have two web sites: Mysite1 (siteno 1) and Mysite2 (siteno 2).
I want to copy one directory or web app from Mysite1 to Mysite2 and I
cant get it to work. Have tried alot of different ways but no one will
work.

Heres a code example

Imports System.DirectoryServices

Public Sub Copy()
Dim oIIS_Source As New DirectoryEntry
"IIS://localhost/w3svc/2/root/test")
Dim oIIS_Target As New
DirectoryEntry("IIS://localhost/w3svc/1/root/test")
Dim oNewDir as DirectoryEntry

oNewDir = oIIS_Source.CopyTo(oIIS_Target)

I get "Path not found" error.

I can create Virtual directories by using DirectoryEntry but I cant
copy one to the other.

Any ideas?
Regards
Mikael

 
 
 

DirectoryEntry and CopyTo function

Post by MVP - ADS » Wed, 09 Jul 2003 01:32:46


DirectoryEntry::CopyTo calls IADsContainer::CopyHere under the hood which is
supposedly only supported by the NDS provider.  I doubt you can use this
with the IIS provider.

IIS may provide a method you can call to do this, but it will likely need to
be called via reflection with the Invoke method.  Unfortunately I don't know
enough about the IIS provider to give you more hints.

Good luck,

Joe K.


Quote:> Hi

> I am struggling to make a Web site/Web Directory copy work. I am using
> the System.DirectoryServices to connect to my localhost machine.

> There I have two web sites: Mysite1 (siteno 1) and Mysite2 (siteno 2).
> I want to copy one directory or web app from Mysite1 to Mysite2 and I
> cant get it to work. Have tried alot of different ways but no one will
> work.

> Heres a code example

> Imports System.DirectoryServices

> Public Sub Copy()
> Dim oIIS_Source As New DirectoryEntry
> "IIS://localhost/w3svc/2/root/test")
> Dim oIIS_Target As New
> DirectoryEntry("IIS://localhost/w3svc/1/root/test")
> Dim oNewDir as DirectoryEntry

> oNewDir = oIIS_Source.CopyTo(oIIS_Target)

> I get "Path not found" error.

> I can create Virtual directories by using DirectoryEntry but I cant
> copy one to the other.

> Any ideas?
> Regards
> Mikael


 
 
 

1. CopyTo(String) method

I'm trying to copy some files from a top level sites
document library to a subsites dl and I'm running into
problems.  Here is my code:

Dim mySite As SPSite = SPControl.GetContextSite(Context)
Dim myWeb As SPWeb = mySite.AllWebs(Top Level Site Name)

Dim strSourceName As String
= "http://ServerName/sites/SiteName/Document
Library/FolderName/"

Dim strDestDocLib As String = mySite.Url.ToString
+ "/SubSiteName/Document Library/"

Dim files As SPFileCollection = myWeb.GetFolder
(strSourceName).Files

Dim i As Integer
For i = 0 To files.Count
files(i).CopyTo(strDestDocLib + files(i).Name)
Next

I'm not sure I have the whole SPSite/SPWeb hierarchy
straight in my head or if I'm doing something else wrong.

Anyone have any ideas?
Michael

2. Count missing chars and numeric

3. Fustratred Webpart - XSL contains() function error - Inherited XPath Functions

4. Nero Text Writing

5. Problem using DirectoryEntry objects

6. ?Saving works to Excel

7. How to set properties using DirectoryEntry object

8. Change standard environment size?

9. DirectoryEntry properties in ASP.NET

10. DirectoryEntry vs IADsOpenDSObject Authentication - differences?

11. DirectoryEntry RefreshCache fails due to access problem - schema retrieval on 3rd party ldap server

12. ASP.net: problem getting DirectoryEntry

13. DirectoryEntry.Exists Method