Application.RenameFolderOnSqlServer Method (String, String, String, String, String, String)

 

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 Sub RenameFolderOnSqlServer (
	strParent As String,
	strOldName As String,
	strNewName As String,
	strServerName As String,
	strServerUserName As String,
	strServerPassword As String
)

Parameters

strParent
Type: System.String

The name of the parent folder.

strOldName
Type: System.String

The name of the existing folder.

strNewName
Type: System.String

The new name of the folder.

strServerName
Type: System.String

The name of the instance of SQL Server.

strServerUserName
Type: System.String

The user name to use when authenticating on the server.

strServerPassword
Type: System.String

The password associated with the strServerUserName account.

The following code example creates a folder on SQL Server, renames it, and then removes it.

Shared  Sub Main(ByVal args() As String)
            ' The variable pkg points to the location
            ' of the ExecuteProcess package sample 
            ' that is installed with the SSIS samples.
            Dim pkg As String =  "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx" 

            Dim app As Application =  New Application() 
            app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", Nothing, Nothing)

            ' Verify that the folder was created.
            Dim ssFolder As Boolean =  app.FolderExistsOnSqlServer("\\myNewFolder","yourserver",Nothing,Nothing) 
            Console.WriteLine("myNewFolderExists? " + ssFolder)

            ' Rename the myNewFolder to myRenamedFolder. 
            app.RenameFolderOnSqlServer("\\", "myNewFolder", "myRenamedFolder", "yourserver", Nothing, Nothing)

            ' Verify that the old folder does not exist.
            ssFolder = app.FolderExistsOnSqlServer("\\myNewFolder", "yourserver", Nothing, Nothing)
            Console.WriteLine("myNewFolderExists has been renamed but still exists? " + ssFolder)

            ' Verify that a folder with the new name does exist.
            ssFolder = app.FolderExistsOnSqlServer("\\myRenamedFolder", "yourserver", Nothing, Nothing)
            Console.WriteLine("myRenamedFolder now exists? " + ssFolder)

            ' Delete the new folder.
            app.RemoveFolderFromSqlServer("\\myRenamedFolder", "yourserver", Nothing, Nothing)

            ' Verify that the folder was removed.
            ssFolder = app.FolderExistsOnSqlServer("\\myRenamedFolder", "yourserver", Nothing, Nothing)
            Console.WriteLine("myRenamedFolder still exists? " + ssFolder)
End Sub

Sample Output:

myNewFolderExists? True

myNewFolderExists has been renamed but still exists? False

myRenamedFolder now exists? True

myRenamedFolder still exists? False

Return to top
Show: