Share via


Application.RenameFolderOnDtsServer(String, String, String, String) Method

Definition

Renames a folder on the specified instance of SQL Server.

public:
 void RenameFolderOnDtsServer(System::String ^ sParent, System::String ^ sOldName, System::String ^ sNewName, System::String ^ sServerName);
public void RenameFolderOnDtsServer (string sParent, string sOldName, string sNewName, string sServerName);
member this.RenameFolderOnDtsServer : string * string * string * string -> unit
Public Sub RenameFolderOnDtsServer (sParent As String, sOldName As String, sNewName As String, sServerName As String)

Parameters

sParent
String

The name of the parent folder.

sOldName
String

The name of the existing folder.

sNewName
String

The new name of the folder.

sServerName
String

The name of the server where the folder is located.

Examples

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);  
        }  
Shared  Sub Main(ByVal args() As String)  
    ' Create a folder named myOldFolder.  
    Dim app As Application =  New Application()   
    app.CreateFolderOnDtsServer("\File System\", "myOldFolder", "yourserver")  

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

    ' Rename myOldFolder to myNewFolder.  
    app.RenameFolderOnDtsServer("File System", "myOldFolder", "myNewFolder", "yourserver")  

    ' Check if 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)  
End Sub  

Sample Output:

Folder exists? True

Old, renamed folder exists? False

New folder exists? True

Applies to