다음을 통해 공유


ServerDocument 생성자

정의

오버로드

ServerDocument(String)

로드할 문서의 전체 경로를 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

ServerDocument(Byte[], String)

로드할 문서를 나타내는 바이트 배열과 해당 문서의 파일 확장명을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

ServerDocument(Stream, String)

로드할 문서를 나타내는 스트림과 해당 문서의 파일 확장명을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

ServerDocument(String, FileAccess)

로드할 문서의 전체 경로와 해당 문서에 대한 파일 액세스를 나타내는 값을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

ServerDocument(String)

로드할 문서의 전체 경로를 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

public:
 ServerDocument(System::String ^ documentPath);
public ServerDocument (string documentPath);
new Microsoft.VisualStudio.Tools.Applications.ServerDocument : string -> Microsoft.VisualStudio.Tools.Applications.ServerDocument
Public Sub New (documentPath As String)

매개 변수

documentPath
String

로드할 문서의 전체 경로입니다.

예외

documentPath 매개 변수가 null이거나, 비어 있거나, 모두 공백 문자로 이루어져 있는 경우

documentPath에서 지정한 파일이 없습니다.

documentPath에서 지정한 파일에 Visual Studio 2010 Tools for Office Runtime 또는 Visual Studio Tools for the Microsoft Office System(버전 3.0 Runtime)으로 만들지 않은 사용자 지정이 있습니다.

documentPath 지정된 파일에는 Visual Studio Tools for Office 런타임에서 지원되지 않는 파일 이름 확장명 이 있습니다.

예제

다음 코드 예제에서는 생성자를 사용하여 ServerDocument(String) 지정된 문서를 로드하는 새 ServerDocument 를 만듭니다. 그런 다음 문서에 첨부된 사용자 지정에 대한 배포 매니페스트의 URL을 표시하는 예제입니다.

이 예제에는 다음 사항이 필요합니다.

  • 콘솔 애플리케이션 프로젝트 또는 다른 비 Office 프로젝트입니다.

  • 다음 어셈블리에 대한 참조:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.dll(프로젝트가 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 경우).

      또는

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll(프로젝트가 .NET Framework 3.5를 대상으로 하는 경우).

  • Imports(Visual Basic의 경우) 또는 using (C#의 경우) 코드 파일 맨 위에 있는 및 Microsoft.VisualStudio.Tools.Applications.Runtime 네임스페이스에 대한 Microsoft.VisualStudio.Tools.Applications 문입니다.

private void CreateServerDocumentFromPath(string documentPath)
{
    int runtimeVersion = 0;
    ServerDocument serverDocument1 = null;

    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
        if (runtimeVersion == 3)
        {
            serverDocument1 = new ServerDocument(documentPath);
            MessageBox.Show("The URL of the deployment manifest is: \n" +
                serverDocument1.DeploymentManifestUrl.ToString());
        }
    }
    catch (System.IO.FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (UnknownCustomizationFileException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document has a file " +
            "extension that is not supported by Visual Studio Tools for Office.");
    }
    finally
    {
        if (serverDocument1 != null)
            serverDocument1.Close();
    }
}
Private Sub CreateServerDocumentFromPath(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0
    Dim serverDocument1 As ServerDocument = Nothing

    Try
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion = 3 Then
            serverDocument1 = New ServerDocument(documentPath)
            MessageBox.Show("The URL of the deployment manifest is: " & vbLf & _
                serverDocument1.DeploymentManifestUrl.ToString())
        End If

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    Catch ex As UnknownCustomizationFileException
        System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
            "extension that is not supported by Visual Studio Tools for Office.")
    Finally
        If Not (serverDocument1 Is Nothing) Then
            serverDocument1.Close()
        End If
    End Try
End Sub

설명

이 생성자를 사용하여 디스크에 있는 문서의 캐시된 데이터 또는 배포 매니페스트 정보에 액세스할 수 있습니다. 이 생성자를 사용하면 지정된 문서가 읽기/쓰기 권한으로 열립니다.

적용 대상

ServerDocument(Byte[], String)

로드할 문서를 나타내는 바이트 배열과 해당 문서의 파일 확장명을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

public:
 ServerDocument(cli::array <System::Byte> ^ bytes, System::String ^ fileType);
public ServerDocument (byte[] bytes, string fileType);
new Microsoft.VisualStudio.Tools.Applications.ServerDocument : byte[] * string -> Microsoft.VisualStudio.Tools.Applications.ServerDocument
Public Sub New (bytes As Byte(), fileType As String)

매개 변수

bytes
Byte[]

로드할 문서를 나타내는 바이트 배열입니다.

fileType
String

마침표(.) 앞에 오는 매개 변수에 bytes 저장된 문서의 파일 이름 확장명입니다. -예: ".xlsx" 또는 ".docx".

예외

매개 변수가 bytes 이거나 null 비어 있습니다.-또는-매개 변수가 fileTypenull 이거나 비어 있거나 공백 문자로 완전히 구성됩니다.

매개 변수는 fileType Visual Studio Tools for Office 런타임에서 지원되지 않는 파일 이름 확장명을 지정합니다.

documentPath에서 지정한 파일에 Visual Studio 2010 Tools for Office Runtime 또는 Visual Studio Tools for the Microsoft Office System(버전 3.0 Runtime)으로 만들지 않은 사용자 지정이 있습니다.

예제

다음 코드 예제에서는 [ServerDocument 생성자(Byte<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument.%23ctor%28System.Byte%5B%5D%2CSy)를 사용합니다. .xlsx 파일 이름 확장명을 가진 Excel 통합 문서가 포함된 바이트 배열에서 새 [ServerDocument 생성자(Byte<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument>)를 만드는 시스템.String%29> 생성자입니다. 그런 다음 이 예제에서는 [ServerDocument 생성자(Byte<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument.Document%2A 속성)> 를 사용하여 문서의 바이트 수를 표시합니다.

이 예제에는 다음 사항이 필요합니다.

  • 콘솔 애플리케이션 프로젝트 또는 다른 비 Office 프로젝트입니다.

  • 다음 어셈블리에 대한 참조:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.dll(프로젝트가 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 경우).

      또는

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll(프로젝트가 .NET Framework 3.5를 대상으로 하는 경우).

  • Imports (Visual Basic의 경우) 또는 using (C#의 경우) 코드 파일 맨 위에 있는 [ServerDocument 생성자(Byte<xref:Microsoft.VisualStudio.Tools.Applications?displayProperty=fullName> 및 [ServerDocument 생성자(Byte<xref:Microsoft.VisualStudio.Tools.Applications.Runtime?displayProperty=fullName> 네임스페이스)에 대한 문입니다.

private void CreateServerDocumentFromByteArray(string documentPath)
{
    int runtimeVersion = 0;
    ServerDocument serverDocument1 = null;
    System.IO.FileStream stream = null;

    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
        if (runtimeVersion == 3)
        {
            // Read the file into a byte array.
            stream = new System.IO.FileStream(
                documentPath, System.IO.FileMode.Open,
                System.IO.FileAccess.Read);
            byte[] buffer = new byte[(int)stream.Length];
            stream.Read(buffer, 0, (int)buffer.Length);

            // Display the number of bytes in the document.
            serverDocument1 = new ServerDocument(buffer,
                "*.xlsx");
            MessageBox.Show("The Document property contains " +
                serverDocument1.Document.Length.ToString() +
                " bytes.");
        }
    }
    catch (System.IO.FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (UnknownCustomizationFileException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document has a file " +
            "extension that is not supported by Visual Studio Tools for Office.");
    }
    finally
    {
        if (serverDocument1 != null)
            serverDocument1.Close();
        if (stream != null)
            stream.Close();
    }
}
Private Sub CreateServerDocumentFromByteArray(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0
    Dim serverDocument1 As ServerDocument = Nothing
    Dim stream As System.IO.FileStream = Nothing

    Try
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion = 3 Then
            ' Read the file into a byte array.
            stream = New System.IO.FileStream(documentPath, System.IO.FileMode.Open, _
                System.IO.FileAccess.Read)
            Dim buffer(Fix(stream.Length)) As Byte
            stream.Read(buffer, 0, Fix(buffer.Length))

            ' Display the number of bytes in the document.
            serverDocument1 = New ServerDocument(buffer, "*.xlsx")
            MessageBox.Show("The Document property contains " & _
                serverDocument1.Document.Length.ToString() & " bytes.")
        End If

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    Catch ex As UnknownCustomizationFileException
        System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
            "extension that is not supported by Visual Studio Tools for Office.")
    Finally
        If Not (serverDocument1 Is Nothing) Then
            serverDocument1.Close()
        End If
        If Not (stream Is Nothing) Then
            stream.Close()
        End If
    End Try
End Sub

설명

이 생성자를 사용하여 이미 메모리에 있는 문서의 캐시된 데이터 또는 배포 매니페스트 정보에 액세스합니다. 이 생성자를 사용하면 읽기/쓰기 권한이 있는 문서가 열립니다.

fileType 매개 변수는 바이트 배열에 저장된 문서의 형식을 결정하는 데만 사용됩니다. 값 fileType 은 문서 수준 사용자 지정에 지원되는 파일 형식 중 하나에 매핑됩니다. 파일을 열려고 시도하지 않습니다. 필요에 따라 전체 파일 이름(예: "Workbook1.xlsx")을 전달할 수 있지만, 이렇게 하면 파일 이름 확장명만 사용됩니다. 지원되는 파일 형식에 대한 자세한 내용은 Document-Level 아키텍처 사용자 지정을 참조하세요.

이 생성자를 호출한 후 문서의 바이트 배열에 액세스하려면 [ServerDocument 생성자(Byte<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument.Document%2A 속성)> 를 사용합니다.

적용 대상

ServerDocument(Stream, String)

로드할 문서를 나타내는 스트림과 해당 문서의 파일 확장명을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

public:
 ServerDocument(System::IO::Stream ^ stream, System::String ^ fileType);
public ServerDocument (System.IO.Stream stream, string fileType);
new Microsoft.VisualStudio.Tools.Applications.ServerDocument : System.IO.Stream * string -> Microsoft.VisualStudio.Tools.Applications.ServerDocument
Public Sub New (stream As Stream, fileType As String)

매개 변수

stream
Stream

로드할 문서를 나타내는 스트림입니다.

fileType
String

마침표(.) 앞에 오는 매개 변수에 bytes 저장된 문서의 파일 이름 확장명입니다. -예: ".xlsx" 또는 ".docx".

예외

매개 변수가 stream 이거나 null 비어 있습니다.-또는-매개 변수가 fileTypenull 이거나 비어 있거나 공백 문자로 완전히 구성됩니다.

stream 매개 변수의 길이가 0이거나 현재 위치가 스트림의 끝에 있는 경우

매개 변수는 fileType Visual Studio Tools for Office 런타임에서 지원되지 않는 파일 이름 확장명을 지정합니다.

documentPath에서 지정한 파일에 Visual Studio 2010 Tools for Office Runtime 또는 Visual Studio Tools for the Microsoft Office System(버전 3.0 Runtime)으로 만들지 않은 사용자 지정이 있습니다.

예제

다음 코드 예제에서는 생성자를 사용하여 ServerDocument(Stream, String) .xlsx 파일 이름 확장명을 가진 Excel 통합 문서가 포함된 에서 FileStreamServerDocument 을 만듭니다. 그런 다음, 코드는 문서에 첨부된 사용자 지정에 대한 배포 매니페스트의 URL을 표시합니다.

이 예제에는 다음 사항이 필요합니다.

  • 콘솔 애플리케이션 프로젝트 또는 다른 비 Office 프로젝트입니다.

  • 다음 어셈블리에 대한 참조:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.dll(프로젝트가 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 경우).

      또는

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll(프로젝트가 .NET Framework 3.5를 대상으로 하는 경우).

  • Imports(Visual Basic의 경우) 또는 using (C#의 경우) 코드 파일 맨 위에 있는 및 Microsoft.VisualStudio.Tools.Applications.Runtime 네임스페이스에 대한 Microsoft.VisualStudio.Tools.Applications 문입니다.

private void CreateServerDocumentFromStream(string documentPath)
{
    int runtimeVersion = 0;
    ServerDocument serverDocument1 = null;
    System.IO.FileStream stream = null;

    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
        if (runtimeVersion == 3)
        {
            stream = new System.IO.FileStream(
                documentPath, System.IO.FileMode.Open);
            serverDocument1 = new ServerDocument(stream,
                "*.xlsx");
            MessageBox.Show("The URL of the deployment manifest is: \n" +
                serverDocument1.DeploymentManifestUrl.ToString());
        }
    }
    catch (System.IO.FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (UnknownCustomizationFileException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document has a file " +
            "extension that is not supported by Visual Studio Tools for Office.");
    }
    finally
    {
        if (serverDocument1 != null)
            serverDocument1.Close();
        if (stream != null)
            stream.Close();
    }
}
Private Sub CreateServerDocumentFromStream(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0
    Dim serverDocument1 As ServerDocument = Nothing
    Dim stream As System.IO.FileStream = Nothing

    Try
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion = 3 Then
            stream = New System.IO.FileStream(documentPath, System.IO.FileMode.Open)
            serverDocument1 = New ServerDocument(stream, "*.xlsx")
            MessageBox.Show("The URL of the deployment manifest is: " & vbLf & _
                serverDocument1.DeploymentManifestUrl.ToString())
        End If

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    Catch ex As UnknownCustomizationFileException
        System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
            "extension that is not supported by Visual Studio Tools for Office.")
    Finally
        If Not (serverDocument1 Is Nothing) Then
            serverDocument1.Close()
        End If
        If Not (stream Is Nothing) Then
            stream.Close()
        End If
    End Try
End Sub

설명

이 생성자를 사용하여 이미 메모리에 있는 문서의 캐시된 데이터 또는 배포 매니페스트 정보에 액세스합니다. 이 생성자를 사용하면 읽기/쓰기 권한이 있는 문서가 열립니다.

fileType 매개 변수는 바이트 배열에 저장된 문서의 형식을 결정하는 데만 사용됩니다. 값 fileType 은 문서 수준 사용자 지정에 지원되는 파일 형식 중 하나에 매핑됩니다. 파일을 열려고 시도하지 않습니다. 필요에 따라 전체 파일 이름(예: "Workbook1.xlsx")을 전달할 수 있지만, 이렇게 하면 파일 이름 확장명만 사용됩니다. 지원되는 파일 형식에 대한 자세한 내용은 Document-Level 아키텍처 사용자 지정을 참조하세요.

이 생성자를 호출한 후 문서의 바이트 배열에 액세스하려면 속성을 사용합니다 Document .

적용 대상

ServerDocument(String, FileAccess)

로드할 문서의 전체 경로와 해당 문서에 대한 파일 액세스를 나타내는 값을 사용하여 ServerDocument 클래스의 새 인스턴스를 초기화합니다.

public:
 ServerDocument(System::String ^ documentPath, System::IO::FileAccess access);
public ServerDocument (string documentPath, System.IO.FileAccess access);
new Microsoft.VisualStudio.Tools.Applications.ServerDocument : string * System.IO.FileAccess -> Microsoft.VisualStudio.Tools.Applications.ServerDocument
Public Sub New (documentPath As String, access As FileAccess)

매개 변수

documentPath
String

로드할 문서의 전체 경로입니다.

access
FileAccess

문서에 대한 파일 액세스를 나타내는 값입니다.

예외

documentPath 매개 변수가 null이거나, 비어 있거나, 모두 공백 문자로 이루어져 있는 경우

access 은 System.IO.FileAccess.Write입니다.

documentPath에서 지정한 파일이 없습니다.

매개 변수로 documentPath 지정된 파일에는 사용자 지정이 없으며 값 access 은 System.IO.FileAccess.Read입니다.

documentPath에서 지정한 파일에 Visual Studio 2010 Tools for Office Runtime 또는 Visual Studio Tools for the Microsoft Office System(버전 3.0 Runtime)으로 만들지 않은 사용자 지정이 있습니다.

documentPath 지정된 파일에는 Visual Studio Tools for Office 런타임에서 지원되지 않는 파일 이름 확장명 이 있습니다.

예제

다음 코드 예제에서는 생성자를 사용하여 ServerDocument(String, FileAccess) 읽기 전용 액세스 권한으로 지정된 문서를 로드하는 새 ServerDocument 을 만듭니다. 그런 다음, 코드는 문서에 첨부된 사용자 지정에 대한 배포 매니페스트의 URL을 표시합니다.

이 예제에는 다음 사항이 필요합니다.

  • 콘솔 애플리케이션 프로젝트 또는 다른 비 Office 프로젝트입니다.

  • 다음 어셈블리에 대한 참조:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.dll(프로젝트가 .NET Framework 4 또는 .NET Framework 4.5를 대상으로 하는 경우).

      또는

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll 및 Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll(프로젝트가 .NET Framework 3.5를 대상으로 하는 경우).

  • Imports(Visual Basic의 경우) 또는 using (C#의 경우) 코드 파일 맨 위에 있는 및 Microsoft.VisualStudio.Tools.Applications.Runtime 네임스페이스에 대한 Microsoft.VisualStudio.Tools.Applications 문입니다.

private void CreateServerDocumentReadOnly(string documentPath)
{
    int runtimeVersion = 0;
    ServerDocument serverDocument1 = null;

    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
        if (runtimeVersion == 3)
        {
            serverDocument1 = new ServerDocument(documentPath,
                System.IO.FileAccess.Read);
            MessageBox.Show("The URL of the deployment manifest is: \n" +
                serverDocument1.DeploymentManifestUrl.ToString());
        }
    }
    catch (System.IO.FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (DocumentNotCustomizedException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not " +
            "have a customization.");
    }
    catch (UnknownCustomizationFileException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document has a file " +
            "extension that is not supported by Visual Studio Tools for Office.");
    }
    finally
    {
        if (serverDocument1 != null)
            serverDocument1.Close();
    }
}
Private Sub CreateServerDocumentReadOnly(ByVal documentPath As String)
    Dim runtimeVersion As Integer = 0
    Dim serverDocument1 As ServerDocument = Nothing

    Try
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath)
        If runtimeVersion = 3 Then
            serverDocument1 = New ServerDocument(documentPath, System.IO.FileAccess.Read)
            MessageBox.Show("The URL of the deployment manifest is: " & vbLf & _
                serverDocument1.DeploymentManifestUrl.ToString())
        End If

    Catch ex As System.IO.FileNotFoundException
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.")
    Catch ex As DocumentNotCustomizedException
        System.Windows.Forms.MessageBox.Show("The specified document does not " & _
            "have a customization.")
    Catch ex As UnknownCustomizationFileException
        System.Windows.Forms.MessageBox.Show("The specified document has a file " & _
            "extension that is not supported by Visual Studio Tools for Office.")
    Finally
        If Not (serverDocument1 Is Nothing) Then
            serverDocument1.Close()
        End If
    End Try
End Sub

설명

읽기 전용 또는 쓰기 전용 액세스 권한으로 문서를 열려면 이 생성자를 사용하여 디스크에 있는 문서의 캐시된 데이터 또는 배포 매니페스트 정보에 액세스할 수 있습니다. 기본적으로 다른 ServerDocument 생성자는 읽기/쓰기 권한이 있는 문서를 엽니다.

적용 대상