مشاركة عبر


ServerDocument المنشئ (String)

تهيئة مثيل جديد من ServerDocumentلفئة استخدام مسار الكامل للمستند إلى يمكن تحميله.

مساحة الاسم:  Microsoft.VisualStudio.Tools.Applications
التجميع:  Microsoft.VisualStudio.Tools.Applications.ServerDocument (في Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)

بناء الجملة

'إقرار
Public Sub New ( _
    documentPath As String _
)
public ServerDocument(
    string documentPath
)

المعلمات

  • documentPath
    النوع: System.String
    مسار الكامل للمستند إلى يمكن تحميله.

استثناءات

استثناء: شرط
ArgumentNullException

documentPathمعلمة هو nullمرجع خالٍ (لا شيء في Visual Basic)أو فارغة أو consهوts من أحرف المسافات البيضاء.

FileNotFoundException

ملف المحدد بواسطة documentPathغير موجود.

DocumentCustomizedWithPreviousRuntimeException

ملف المحدد مع documentPathله تخصيص التي لم يتم تاريخ الإنشاء مع Visual Studio Tools لـ Office Runtimeأو أدوات ‏‫Visual Studio لنظام Microsoft المكتب 2010 Suite (الإصدار 3.0 وقت التشغيل).

UnknownCustomizationFileException

الملف المحدد بواسطة documentPathملف له ملحق اسم هو غير معتمد من قبل Visual Studio Tools لوقت تشغيل Office.

ملاحظات

استخدم هذا الدالة الإنشائية الوصول بيانات أو نشرها بيان المعلومات المخزنة مؤقتاً في مستند موجود تشغيل قرص. عند استخدام هذا الدالة الإنشائية، يتم فتح مستند المعين له حق الوصول للقراءة والكتابة.

أمثلة

يستخدم المثال التالي رمز ServerDocument(String)الدالة الإنشائية لإنشاء جديد ServerDocumentالتي تحمل مستند المحدد. المثال ثم dهوplays URL الخاص بالنشر البيان للتخصيص التي هو المرفق بالمستند.

يتطلب هذا المثال:

  • مشروع تطبيقات وحدة تحكم أو بعض المشاريع بخلاف المكتب الأخرى.

  • مراجع إلى تجميعات التالية:

    • Microsoft.VisualStudio.أدوات.Applications.ServerDocument.dll و Microsoft.VisualStudio.أدوات.Applications.وقت التشغيل.dll (إذا كان مشروع تستهدف .NET Framework 4).

      أو

    • Microsoft.VisualStudio.أدوات.Applications.ServerDocument.v10.0.dll و Microsoft.VisualStudio.أدوات.Applications.وقت التشغيل.v9.0.dll (إذا كان مشروع تستهدف 3.5 إطار عمل.NET).

  • Imports (for Visual Basic) or using (for C#) statements for Microsoft.VisualStudio.Tools.Applications and Microsoft.VisualStudio.Tools.Applications.Runtime namespaces at the top of your code file.

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

أمن NET Framework.

راجع أيضًَا

المرجع

ServerDocument الفئة

ServerDocument الأعضاء

ServerDocument التحميل الزائد

Microsoft.VisualStudio.Tools.Applications مساحة الاسم