Konstruktor ServerDocument — (String)

Inicjuje nowe wystąpienie ServerDocument klasy przy użyciu pełną ścieżkę dokumentu do załadowania.

Przestrzeń nazw:  Microsoft.VisualStudio.Tools.Applications
Zestaw:  Microsoft.VisualStudio.Tools.Applications.ServerDocument (w Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)

Składnia

'Deklaracja
Public Sub New ( _
    documentPath As String _
)
public ServerDocument(
    string documentPath
)

Parametry

  • documentPath
    Typ: System.String
    Pełna ścieżka dokumentu do załadowania.

Wyjątki

Wyjątek Warunek
ArgumentNullException

documentPath Jest parametr nullodwołanie o wartości null (Nothing w języku Visual Basic) lub pusty lub zawiera tylko znaki odstępu.

FileNotFoundException

W pliku określonym przez documentPath nie istnieje.

DocumentCustomizedWithPreviousRuntimeException

W pliku określonym przez documentPath ma dostosowania, który nie został utworzony z programu Visual Studio 2010 Tools dla środowiska Office Runtime lub Visual Studio Tools dla pakietu Microsoft Office system (wersja 3.0 Runtime).

UnknownCustomizationFileException

W pliku określonym przez documentPath ma rozszerzenie nazwy pliku, który nie jest obsługiwany przez Visual Studio 2010 Tools for Office Runtime.

Uwagi

Umożliwia dostęp do pamięci podręcznej danych lub wdrożenia manifestu informacji w dokumencie, który znajduje się na dysku tego konstruktora.Korzystając z tego konstruktora, określony dokument jest otwarty z dostępem do odczytu i zapisu.

Przykłady

Następujący kod w przykładzie wykorzystano ServerDocument(String) Konstruktor, aby utworzyć nową ServerDocument który ładuje określonego dokumentu.Następnie w przykładzie wyświetlono adresu URL manifestu wdrażania dla dostosowania, który jest dołączony do dokumentu.

W tym przykładzie wymaga:

  • Projekt aplikacji konsoli lub innych projektów nienależących do pakietu Office.

  • Odwołania do następujących zestawów:

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll i Microsoft.VisualStudio.Tools.Applications.Runtime.dll (jeśli cele projektu .NET Framework 4 lub .NET Framework 4.5).

      lub

    • Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll i Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (Jeśli projekt jest przeznaczony dla.NET Framework 3.5).

  • Imports(dla Visual Basic) lub using (w przypadku C#) oświadczenia dla Microsoft.VisualStudio.Tools.Applications i Microsoft.VisualStudio.Tools.Applications.Runtime obszarów nazw u góry pliku kodu.

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
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();
    }
}

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

ServerDocument Klasa

Przeciążenie ServerDocument

Przestrzeń nazw Microsoft.VisualStudio.Tools.Applications