ServerDocument المنشئ (String, FileAccess)
تهيئة مثيل جديد من ServerDocumentلفئة استخدام مسار الكامل للمستند المراد تحميله وقيمة تشير ملف الوصول للتطبيق.
مساحة الاسم: Microsoft.VisualStudio.Tools.Applications
التجميع: Microsoft.VisualStudio.Tools.Applications.ServerDocument (في Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll)
بناء الجملة
'إقرار
Public Sub New ( _
documentPath As String, _
access As FileAccess _
)
public ServerDocument(
string documentPath,
FileAccess access
)
المعلمات
- documentPath
النوع: System.String
مسار الكامل للمستند إلى يمكن تحميله.
- access
النوع: System.IO.FileAccess
القيمة تشير ملف الوصول للمستند.
استثناءات
استثناء: | شرط |
---|---|
ArgumentNullException | documentPathمعلمة هو nullمرجع خالٍ (لا شيء في Visual Basic)أو فارغة أو consهوts من أحرف المسافات البيضاء. |
ArgumentException | The value ofaccessهوSystem.IO.FileAccess.Write. |
FileNotFoundException | ملف المحدد بواسطة documentPathغير موجود. |
DocumentNotCustomizedException | الملف المحدد بواسطة documentPathلم يكن معلمة تخصيص، و القيمة accessهو System.IO.FileAccess.Read. |
DocumentCustomizedWithPreviousRuntimeException | ملف المحدد مع documentPathله تخصيص التي لم يتم تاريخ الإنشاء مع Visual Studio Tools لـ Office Runtimeأو أدوات Visual Studio لنظام Microsoft المكتب 2010 Suite (الإصدار 3.0 وقت التشغيل). |
UnknownCustomizationFileException | الملف المحدد بواسطة documentPathملف له ملحق اسم هو غير معتمد من قبل Visual Studio Tools لوقت تشغيل Office. |
ملاحظات
استخدم هذا الدالة الإنشائية الوصول إلى ذاكرة التخزين المؤقت بيانات أو نشرها بيان المعلومات في مستند موجود تشغيل قرص إذا كنت تريد فتح المستند بالقراءة أو الكتابة-فقط الوصول إليه. بواسطة افتراضية و غير ذلك ServerDocumentالمنشئات بفتح مستند بالقراءة/حق الوصول للكتابة.
أمثلة
يستخدم المثال التالي رمز ServerDocument(String, FileAccess)الدالة الإنشائية لإنشاء جديد ServerDocumentالذي يقوم بتحميل مستند محدد بالقراءة فقط الوصول. تعليمات برمجية ثم يعرض عنوان 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 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
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();
}
}
أمن NET Framework.
- الثقة الكاملة للمتصل الفوري. يتعذر استخدام هذا العضو بواسطة التعليمات البرمجية الموثوق بها جزئيًا. لمزيد من المعلومات، راجع باستخدام مكتبات من تعليمات برمجية موثوق بها جزئي.