Export (0) Print
Expand All

Application.RemoveFolderFromSqlServer Method

Removes the specified folder from the specified instance of SQL Server.

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

public void RemoveFolderFromSqlServer(
	string strFolderName,
	string strServerName,
	string strServerUserName,
	string strServerPassword
)

Parameters

strFolderName
Type: System.String
The name of the folder to delete.
strServerName
Type: System.String
The name of the instance of SQL Server to remove the folder from.
strServerUserName
Type: System.String
The SQL Server login name if you use SQL Server Authentication to log into the server; otherwise, null if you use Windows Authentication.
strServerPassword
Type: System.String
The SQL Server login password if you use SQL Server Authentication to log into the server; otherwise, null if you use Windows Authentication.

The following code example creates a folder on SQL Server, renames it, and then removes it by using RemoveFolderFromSqlServer. It also verifies the existence of the folder several times by using FolderExistsOnSqlServer.

static void Main(string[] args)
        {
            // The variable pkg points to the location
            // of the ExecuteProcess package sample 
            // that is installed with the SSIS samples.
            string pkg = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            Application app = new Application();
            app.CreateFolderOnSqlServer("\\", "myNewFolder", "yourserver", null, null);
            
            // Verify that the folder was created.
            Boolean ssFolder = app.FolderExistsOnSqlServer("\\myNewFolder", "yourserver", null, null);
            Console.WriteLine("myNewFolderExists? " + ssFolder);

            // Rename myNewFolder to myRenamedFolder. 
            app.RenameFolderOnSqlServer("\\", "myNewFolder", "myRenamedFolder", "yourserver", null, null);

            // Verify that the old folder does not exist.
            ssFolder = app.FolderExistsOnSqlServer("\\myNewFolder", "yourserver", null, null);
            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", null, null);
            Console.WriteLine("myRenamedFolder now exists? " + ssFolder);

            // Delete the folder.
            app.RemoveFolderFromSqlServer("\\myRenamedFolder", "yourserver", null, null);

            // Verify that the folder was removed.
            ssFolder = app.FolderExistsOnSqlServer("\\myRenamedFolder", "yourserver", null, null);
            Console.WriteLine("myRenamedFolder still exists? " + ssFolder);
        }

Sample Output:

myNewFolderExists? True

myNewFolderExists has been renamed but still exists? False

myRenamedFolder now exists? True

myRenamedFolder still exists? False

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft