共用方式為


Application.RenameFolderOnSqlServer Method

Renames a folder on the specified instance of SQL Server.

命名空間: Microsoft.SqlServer.Dts.Runtime
組件: 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 _
)
public void RenameFolderOnSqlServer (
    string strParent,
    string strOldName,
    string strNewName,
    string strServerName,
    string strServerUserName,
    string strServerPassword
)
public:
void RenameFolderOnSqlServer (
    String^ strParent, 
    String^ strOldName, 
    String^ strNewName, 
    String^ strServerName, 
    String^ strServerUserName, 
    String^ strServerPassword
)
public void RenameFolderOnSqlServer (
    String strParent, 
    String strOldName, 
    String strNewName, 
    String strServerName, 
    String strServerUserName, 
    String strServerPassword
)
public function RenameFolderOnSqlServer (
    strParent : String, 
    strOldName : String, 
    strNewName : String, 
    strServerName : String, 
    strServerUserName : String, 
    strServerPassword : String
)

參數

  • strParent
    The name of the parent folder.
  • strOldName
    The name of the existing folder.
  • strNewName
    The new name of the folder.
  • strServerName
    The name of the instance of SQL Server.
  • strServerUserName
    The user name to use when authenticating on the server.
  • strServerPassword
    The password associated with the strServerUserName account.

範例

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

[C#]

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\90\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 the 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 new 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);
        }
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\90\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

執行緒安全性

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

平台

開發平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

目標平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

請參閱

參考

Application Class
Application Members
Microsoft.SqlServer.Dts.Runtime Namespace