共用方式為


SPFolder.MoveTo method

將資料夾和其內容移至新的資料夾,在指定的 URL。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public Sub MoveTo ( _
    strNewUrl As String _
)
'用途
Dim instance As SPFolder
Dim strNewUrl As String

instance.MoveTo(strNewUrl)
public void MoveTo(
    string strNewUrl
)

參數

  • strNewUrl
    Type: System.String

    字串,指定新資料夾的 URL。

備註

MoveTo方法僅適用於單一站台的內容。

Examples

下列程式碼範例將一個資料夾從網站中指定的子資料夾移至另一個資料夾。

Dim site As SPWeb = SPControl.GetContextWeb(Context)

If site.GetFolder("Shared Documents/Source_Subfolder_Name").Exists Then

    Dim moveFolder As SPFolder = web.GetFolder
        ("Shared Documents/Source_Subfolder_Name")

    moveFolder.MoveTo("DocLib_Name/Destination_Subfolder_Name")

End If
SPWeb oWebsite = SPContext.Current.Web;
if (oWebsite.GetFolder("Shared Documents/Source_Subfolder_Name").Exists)
{
    SPFolder oFolderSrc = oWebsite.GetFolder("Shared Documents/Source_Subfolder_Name");

    oFolderSrc.MoveTo("DocLib_Name/Destination_Subfolder_Name");
}

請參閱

參照

SPFolder class

SPFolder members

Microsoft.SharePoint namespace