Microsoft KB Archive/219573

= FP2000: Folders.Add Method Fails on External Files =

Article ID: 219573

Article Last Modified on 8/30/2002

-

APPLIES TO


 * Microsoft FrontPage 2000 Standard Edition

-



This article was previously published under Q219573



SYMPTOMS
When you use the Folders.Add method, you receive the following run-time error message:

Run-time error '-2147467259 (80004005)':

Server Error: 'file:///C:/MyFolder' does not refer to a page or folder in this web. It may be a page or folder in a sub web, or it could be a badly formed URL.

where MyFolder is the name of the folder you specified to add.



CAUSE
You can not add or import folders to your web that are outside of your web.



WORKAROUND
The correct way to use Folders.Add method is to create a folder in your web. For example, the following code will create a folder named "MyNewFolder" in your current web: Sub CreateFolder Dim newfolder as WebFolder Set newfolder=ActiveWeb.RootFolder.Folders.Add("MyNewFolder") End Sub WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. To workaround this behavior, use the following sample code. This code creates a new folder called "MyNewFolder" and places all the files from the specified folder into that folder.

NOTE: You must have at least one file in the folder that you specify. To insert the code, follow these steps:  On the Tools menu, point to Macro, and then click Visual Basic Editor. On the Insert menu, click Module.  In the Module you just created, type the following code: Sub importfiles Dim mypath, myname, myfile Dim newfolder As WebFolder

mypath = "c:\My Documents\" '  This is the path location that you wish to get files from.

myname = Dir(mypath, vbDirectory)

Set newfolder = ActiveWeb.RootFolder.Folders.Add("MyNewFolder") '  This creates a new folder in the current web named MyNewFolder

'  The following loop goes through each file in each folder in the '  specified file location.

Do While myname <> "" If myname <> "." And myname <> ".." Then If (GetAttr(mypath & myname) And vbNormal) = vbNormal Then ActiveWeb.RootFolder.Folders("MyNewFolder").Files.Add (myname) '  This adds each file name to the folder in the current web '  in the folder named MyNewFolder End If       End If        myname = Dir Loop End Sub  On the Run menu, click Run, or press F5.

Additional query words: front page

Keywords: kbprb KB219573

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.