DTSFileSystemOperation 열거형

정의

수행할 파일 시스템 작업을 나타냅니다.

public enum class DTSFileSystemOperation
public enum DTSFileSystemOperation
type DTSFileSystemOperation = 
Public Enum DTSFileSystemOperation
상속
DTSFileSystemOperation

필드

CopyDirectory 6

FileSystemTask가 디렉터리를 복사합니다. IsDestinationPathVariableIsSourcePathVariable을 모두 설정해야 합니다.

CopyFile 0

FileSystemTask가 파일을 복사합니다. IsDestinationPathVariableIsSourcePathVariable을 모두 설정해야 합니다.

CreateDirectory 5

FileSystemTask가 디렉터리를 만듭니다. IsSourcePathVariable을 설정해야 합니다.

DeleteDirectory 8

FileSystemTask가 디렉터리를 삭제합니다. IsSourcePathVariable을 설정해야 합니다.

DeleteDirectoryContent 9

FileSystemTask가 디렉터리의 내용을 삭제합니다. IsSourcePathVariable을 설정해야 합니다.

DeleteFile 2

FileSystemTask가 파일을 삭제합니다. IsSourcePathVariable을 설정해야 합니다.

MoveDirectory 7

FileSystemTask가 디렉터리를 이동합니다. IsDestinationPathVariableIsSourcePathVariable을 모두 설정해야 합니다.

MoveFile 1

FileSystemTask가 파일을 이동합니다. IsDestinationPathVariableIsSourcePathVariable을 모두 설정해야 합니다.

RenameFile 3

FileSystemTask가 파일의 이름을 바꿉니다. IsDestinationPathVariableIsSourcePathVariable을 모두 설정해야 합니다.

SetAttributes 4

FileSystemTask가 파일 또는 디렉터리의 특성을 설정합니다. IsDestinationPathVariableIsSourcePathVariable을 모두 설정해야 합니다.

예제

다음 코드 예제에서는 패키지에서 FileSystemTask as를 Executable 만듭니다. 두 FileSystemTask 하위 폴더와 .txt 파일이 포함된 테스트 폴더를 다른 폴더에 복사합니다. 속성에 표시된 대로 수행할 작업이 로 설정되어 CopyDirectory있으므로 폴더 및 하위 폴더가 Operation 복사됩니다.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;  

namespace FileSystemTask_API  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            String sourceDir = @"C:\TestFolder";  
            String destDir = @"C:\MyNewTestFolder";  

            Package pkg = new Package();  
            Executable exec1 = pkg.Executables.Add("STOCK:FileSystemTask");  
            TaskHost th = exec1 as TaskHost;  

            // Show how to set properties using the TaskHost Properties.  
            // Set the properties to copy an existing folder, which contains two subfolders  
            // and a .txt file, to another existing folder on the C:\ drive.  

            // The source or destination files are not in a variable, so set   
            // IsSourcePathVariable and IsDestinationPathVariable to false.  
            th.Properties["IsSourcePathVariable"].SetValue(th, false);  
            th.Properties["IsDestinationPathVariable"].SetValue(th, false);  

            // Create the File connection manager for the source.  
            ConnectionManager cm = pkg.Connections.Add("FILE");  
            cm.Name = "The FILE connection manager";  
            cm.ConnectionString = sourceDir;  
            cm.Properties["FileUsageType"].SetValue(cm, DTSFileConnectionUsageType.FolderExists);  

            // Create the File connection manager for the destination.  
            ConnectionManager cmdest = pkg.Connections.Add("FILE");  
            cmdest.Name = "The destination FILE connection manager";  
            cmdest.ConnectionString = destDir;  
            cmdest.Properties["FileUsageType"].SetValue(cmdest, DTSFileConnectionUsageType.FolderExists);  

            // Set the source property and destination properties  
            // for the task.  
            th.Properties["Source"].SetValue(th, cm.Name);  
            th.Properties["Destination"].SetValue(th, cmdest.Name);  

            // The operation to perform is to copy all the files and  
             // subfolders in a folder.  
            // Do not overwrite the destination information   
            // if it exists.  
            th.Properties["Operation"].SetValue(th, DTSFileSystemOperation.CopyDirectory);  
            th.Properties["OperationName"].SetValue(th, "Copy TestFolder");  
            th.Properties["OverwriteDestinationFile"].SetValue(th, false);  

            // Set the attribute of the folder to be read-only.  
            th.Properties["Attributes"].SetValue(th, DTSFileSystemAttributes.ReadOnly);  
            // Multiple attributes can be set. The next line of code,  
            // commented out, shows how to do that.  
            //th.Properties["Attributes"].SetValue(th, DTSFileSystemAttributes.ReadOnly | DTSFileSystemAttributes.Hidden);  

            // Run the task and copy the folder.  
            DTSExecResult result = pkg.Execute();  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask  

Namespace FileSystemTask_API  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim sourceDir As String =  "C:\TestFolder"   
            Dim destDir As String =  "C:\MyNewTestFolder"   

            Dim pkg As Package =  New Package()   
            Dim exec1 As Executable =  pkg.Executables.Add("STOCK:FileSystemTask")   
            Dim th As TaskHost =  exec1 as TaskHost   

            ' Show how to set properties using the TaskHost Properties.  
            ' Set the properties to copy an existing folder, which contains two subfolders  
            ' and a .txt file, to another existing folder on the C:\ drive.  

            ' The source or destination files are not in a variable, so set   
            ' IsSourcePathVariable and IsDestinationPathVariable to false.  
            th.Properties("IsSourcePathVariable").SetValue(th, False)  
            th.Properties("IsDestinationPathVariable").SetValue(th, False)  

            ' Create the File connection manager for the source.  
            Dim cm As ConnectionManager =  pkg.Connections.Add("FILE")   
            cm.Name = "The FILE connection manager"  
            cm.ConnectionString = sourceDir  
            cm.Properties("FileUsageType").SetValue(cm, DTSFileConnectionUsageType.FolderExists)  

            ' Create the File connection manager for the destination.  
            Dim cmdest As ConnectionManager =  pkg.Connections.Add("FILE")   
            cmdest.Name = "The destination FILE connection manager"  
            cmdest.ConnectionString = destDir  
            cmdest.Properties("FileUsageType").SetValue(cmdest, DTSFileConnectionUsageType.FolderExists)  

            ' Set the source property and destination properties  
            ' for the task.  
            th.Properties("Source").SetValue(th, cm.Name)  
            th.Properties("Destination").SetValue(th, cmdest.Name)  

            ' The operation to perform is to copy all the files and  
             ' subfolders in a folder.  
            ' Do not overwrite the destination information   
            ' if it exists.  
            th.Properties("Operation").SetValue(th, DTSFileSystemOperation.CopyDirectory)  
            th.Properties("OperationName").SetValue(th, "Copy TestFolder")  
            th.Properties("OverwriteDestinationFile").SetValue(th, False)  

            ' Set the attribute of the folder to be read-only.  
            th.Properties("Attributes").SetValue(th, DTSFileSystemAttributes.ReadOnly)  
            ' Multiple attributes can be set. The next line of code,  
            ' commented out, shows how to do that.  
            'th.Properties["Attributes"].SetValue(th, DTSFileSystemAttributes.ReadOnly | DTSFileSystemAttributes.Hidden);  

            ' Run the task and copy the folder.  
            Dim result As DTSExecResult =  pkg.Execute()   
        End Sub  
    End Class  
End Namespace  

적용 대상