Application.RenameFolderOnDtsServer Method

Renames a folder on the specified instance of SQL Server.

Namespace:  Microsoft.SqlServer.Dts.Runtime
Assembly:  Microsoft.SqlServer.ManagedDTS (in Microsoft.SqlServer.ManagedDTS.dll)

public void RenameFolderOnDtsServer(
	string sParent,
	string sOldName,
	string sNewName,
	string sServerName


Type: System.String
The name of the parent folder.
Type: System.String
The name of the existing folder.
Type: System.String
The new name of the folder.
Type: System.String
The name of the server where the folder is located.

The following code example creates a folder within the Integration Services services hierarchy, verifies that the folder has been created, renames it, verifies that the old name is still recognized as a folder, and then verifies whether the new folder name is found.

static void Main(string[] args)
            // Create a folder named myOldFolder.
            Application app = new Application();
            app.CreateFolderOnDtsServer(@"\File System\", "myOldFolder", "yourserver");

            // Verify that creation was successful.
            Boolean folderExists = app.FolderExistsOnDtsServer(@"File System\myOldFolder", "yourserver");
            Console.WriteLine("Folder exists? " + folderExists);

            // Rename myOldFolder to myNewFolder.
            app.RenameFolderOnDtsServer(@"File System", "myOldFolder", "myNewFolder", "yourserver");

            // Verify that the old folder still exists.
            folderExists = app.FolderExistsOnDtsServer(@"File System\myOldFolder", "yourserver");
            Console.WriteLine("Old, renamed folder exists? " + folderExists);

            // Verify that the folder exists with the new name. 
            folderExists = app.FolderExistsOnDtsServer(@"File System\myNewFolder", "yourserver");
            Console.WriteLine("New folder exists? " + folderExists);

Sample Output:

Folder exists? True

Old, renamed folder exists? False

New folder exists? True

Community Additions