ServerDocument Oluşturucular
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
Aşırı Yüklemeler
ServerDocument(String) |
Yüklenecek belgenin ServerDocument tam yolunu kullanarak sınıfının yeni bir örneğini başlatır. |
ServerDocument(Byte[], String) |
Yüklenecek belgeyi ve belgenin ServerDocument dosya adı uzantısını temsil eden bir bayt dizisi kullanarak sınıfının yeni bir örneğini başlatır. |
ServerDocument(Stream, String) |
Yüklenecek belgeyi ve belgenin ServerDocument dosya adı uzantısını temsil eden bir akış kullanarak sınıfının yeni bir örneğini başlatır. |
ServerDocument(String, FileAccess) |
Yüklenecek belgenin ServerDocument tam yolunu ve belge için dosya erişimini gösteren bir değeri kullanarak sınıfının yeni bir örneğini başlatır. |
ServerDocument(String)
Yüklenecek belgenin ServerDocument tam yolunu kullanarak sınıfının yeni bir örneğini başlatır.
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)
Parametreler
- documentPath
- String
Yüklenecek belgenin tam yolu.
Özel durumlar
documentPath
Parametresi boş null
veya boş ya da tamamen boşluk karakterlerinden oluşuyor.
tarafından documentPath
belirtilen dosya yok.
tarafından documentPath
belirtilen dosya, Office Çalışma Zamanı için Visual Studio 2010 Araçları veya Microsoft Office sistemi (sürüm 3.0 Çalışma Zamanı) için Visual Studio Araçları ile oluşturulmamış bir özelleştirmeye sahip.
tarafından documentPath
belirtilen dosya, Office için Visual Studio Araçları çalışma zamanı tarafından desteklenmeyen bir dosya adı uzantısına sahip.
Örnekler
Aşağıdaki kod örneği, belirtilen belgeyi ServerDocument(String) yükleyen yeni ServerDocument bir oluşturmak için oluşturucuyu kullanır. Örnek daha sonra, belgeye eklenen özelleştirme için dağıtım bildiriminin URL'sini görüntüler.
Bu örnek şunları gerektirir:
Bir konsol uygulaması projesi veya başka bir Office dışı proje.
Aşağıdaki derlemelere başvurur:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (proje .NET Framework 4 veya .NET Framework 4.5'i hedefliyorsa).
veya
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (proje .NET Framework 3.5'i hedefliyorsa).
Imports
(Visual Basic için) veyausing
kod dosyanızın üst kısmındaki ve Microsoft.VisualStudio.Tools.Applications.Runtime ad alanları için Microsoft.VisualStudio.Tools.Applications (C#için) deyimleri.
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
Açıklamalar
Diskteki bir belgedeki önbelleğe alınmış verilere veya dağıtım bildirimi bilgilerine erişmek için bu oluşturucuyu kullanın. Bu oluşturucuyu kullandığınızda, belirtilen belge okuma/yazma erişimiyle açılır.
Şunlara uygulanır
ServerDocument(Byte[], String)
Yüklenecek belgeyi ve belgenin ServerDocument dosya adı uzantısını temsil eden bir bayt dizisi kullanarak sınıfının yeni bir örneğini başlatır.
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)
Parametreler
- bytes
- Byte[]
Yüklenecek belgeyi temsil eden bir bayt dizisi.
- fileType
- String
Parametrede depolanan ve önünde nokta (.) bulunan belgenin bytes
dosya adı uzantısı —örneğin, ".xlsx" veya ".docx".
Özel durumlar
bytes
Parametre boş null
veya boş.-ya da-Parametre fileType
boş null
veya tamamen boşluk karakterlerinden oluşuyor.
parametresi, fileType
Office için Visual Studio Araçları çalışma zamanı tarafından desteklenmeyen bir dosya adı uzantısı belirtir.
tarafından documentPath
belirtilen dosya, Office Çalışma Zamanı için Visual Studio 2010 Araçları veya Microsoft Office sistemi (sürüm 3.0 Çalışma Zamanı) için Visual Studio Araçları ile oluşturulmamış bir özelleştirmeye sahip.
Örnekler
Aşağıdaki kod örneğinde [ServerDocument Oluşturucu (Byte<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument.%23ctor%28System.Byte%5B%5D%2CSystem) kullanılmaktadır .String%29> oluşturucu, .xlsx dosya adı uzantısına sahip bir Excel çalışma kitabı içeren bayt dizisinden yeni bir [ServerDocument Oluşturucu (Byte<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument> ) oluşturur. Örnek daha sonra belgedeki bayt sayısını görüntülemek için [ServerDocument Oluşturucu (Byte<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument.Document%2A> özelliğini kullanır.
Bu örnek şunları gerektirir:
Bir konsol uygulaması projesi veya başka bir Office dışı proje.
Aşağıdaki derlemelere başvurur:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (proje .NET Framework 4 veya .NET Framework 4.5'i hedefliyorsa).
veya
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (proje .NET Framework 3.5'i hedefliyorsa).
Imports
Kod dosyanızın üst kısmındaki [ServerDocument Oluşturucu (Byte<xref:Microsoft.VisualStudio.Tools.Applications?displayProperty=fullName> ve [ServerDocument Oluşturucu (Byte<xref:Microsoft.VisualStudio.Tools.Applications.Runtime?displayProperty=fullName> ad alanları için Visual Basic) veyausing
(C#için) deyimleri.
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
Açıklamalar
Zaten bellekte olan bir belgedeki önbelleğe alınmış verilere veya dağıtım bildirimi bilgilerine erişmek için bu oluşturucuyu kullanın. Bu oluşturucuyu kullandığınızda, belge okuma/yazma erişimiyle açılır.
fileType
parametresi yalnızca bayt dizisinde depolanan belge türünü belirlemek için kullanılır. değeri fileType
, belge düzeyinde özelleştirmeler için desteklenen dosya türlerinden biriyle eşlenir. Dosyayı açmaya çalışılır. İsteğe bağlı olarak tam bir dosya adı ("Workbook1.xlsx") geçirebilirsiniz, ancak bunu yaparsanız yalnızca dosya adı uzantısı kullanılır. Desteklenen dosya türleri hakkında daha fazla bilgi için bkz . Document-Level Özelleştirme mimarisi.
Bu oluşturucuyu çağırdıktan sonra belgenin bayt dizisine erişmek için [ServerDocument Oluşturucu (Bayt<xref:Microsoft.VisualStudio.Tools.Applications.ServerDocument.Document%2A> özelliğini kullanın.
Şunlara uygulanır
ServerDocument(Stream, String)
Yüklenecek belgeyi ve belgenin ServerDocument dosya adı uzantısını temsil eden bir akış kullanarak sınıfının yeni bir örneğini başlatır.
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)
Parametreler
- stream
- Stream
Yüklenecek belgeyi temsil eden akış.
- fileType
- String
Parametrede depolanan ve önünde nokta (.) bulunan belgenin bytes
dosya adı uzantısı —örneğin, ".xlsx" veya ".docx".
Özel durumlar
stream
Parametre boş null
veya boş.-ya da-Parametre fileType
boş null
veya tamamen boşluk karakterlerinden oluşuyor.
Parametresinin stream
uzunluğu sıfırdır veya geçerli konumu akışın sonundadır.
parametresi, fileType
Office için Visual Studio Araçları çalışma zamanı tarafından desteklenmeyen bir dosya adı uzantısı belirtir.
tarafından documentPath
belirtilen dosya, Office Çalışma Zamanı için Visual Studio 2010 Araçları veya Microsoft Office sistemi (sürüm 3.0 Çalışma Zamanı) için Visual Studio Araçları ile oluşturulmamış bir özelleştirmeye sahip.
Örnekler
Aşağıdaki kod örneği, .xlsx dosya adı uzantısına sahip bir Excel çalışma kitabı içeren bir FileStream çalışma kitabından yeni ServerDocument bir oluşturmak için oluşturucuyu kullanırServerDocument(Stream, String). Kod daha sonra, belgeye eklenen özelleştirme için dağıtım bildiriminin URL'sini görüntüler.
Bu örnek şunları gerektirir:
Bir konsol uygulaması projesi veya başka bir Office dışı proje.
Aşağıdaki derlemelere başvurur:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (proje .NET Framework 4 veya .NET Framework 4.5'i hedefliyorsa).
veya
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (proje .NET Framework 3.5'i hedefliyorsa).
Imports
(Visual Basic için) veyausing
kod dosyanızın üst kısmındaki ve Microsoft.VisualStudio.Tools.Applications.Runtime ad alanları için Microsoft.VisualStudio.Tools.Applications (C#için) deyimleri.
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
Açıklamalar
Zaten bellekte olan bir belgedeki önbelleğe alınmış verilere veya dağıtım bildirimi bilgilerine erişmek için bu oluşturucuyu kullanın. Bu oluşturucuyu kullandığınızda, belge okuma/yazma erişimiyle açılır.
fileType
parametresi yalnızca bayt dizisinde depolanan belge türünü belirlemek için kullanılır. değeri fileType
, belge düzeyinde özelleştirmeler için desteklenen dosya türlerinden biriyle eşlenir. Dosyayı açmaya çalışılır. İsteğe bağlı olarak tam bir dosya adı ("Workbook1.xlsx") geçirebilirsiniz, ancak bunu yaparsanız yalnızca dosya adı uzantısı kullanılır. Desteklenen dosya türleri hakkında daha fazla bilgi için bkz . Document-Level Özelleştirme mimarisi.
Bu oluşturucuyu çağırdıktan sonra belgenin bayt dizisine Document erişmek için özelliğini kullanın.
Şunlara uygulanır
ServerDocument(String, FileAccess)
Yüklenecek belgenin ServerDocument tam yolunu ve belge için dosya erişimini gösteren bir değeri kullanarak sınıfının yeni bir örneğini başlatır.
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)
Parametreler
- documentPath
- String
Yüklenecek belgenin tam yolu.
- access
- FileAccess
Belge için dosya erişimini gösteren değer.
Özel durumlar
documentPath
Parametresi boş null
veya boş ya da tamamen boşluk karakterlerinden oluşuyor.
değeri access
System.IO.FileAccess.Write değeridir.
tarafından documentPath
belirtilen dosya yok.
parametresi tarafından documentPath
belirtilen dosyanın özelleştirmesi yoktur ve değeri access
System.IO.FileAccess.Read'dir.
tarafından documentPath
belirtilen dosya, Office Çalışma Zamanı için Visual Studio 2010 Araçları veya Microsoft Office sistemi (sürüm 3.0 Çalışma Zamanı) için Visual Studio Araçları ile oluşturulmamış bir özelleştirmeye sahip.
tarafından documentPath
belirtilen dosya, Office için Visual Studio Araçları çalışma zamanı tarafından desteklenmeyen bir dosya adı uzantısına sahip.
Örnekler
Aşağıdaki kod örneği, salt okunur erişime sahip belirtilen bir belgeyi yükleyen yeni ServerDocument bir belge oluşturmak için oluşturucuyu kullanırServerDocument(String, FileAccess). Kod daha sonra, belgeye eklenen özelleştirme için dağıtım bildiriminin URL'sini görüntüler.
Bu örnek şunları gerektirir:
Bir konsol uygulaması projesi veya başka bir Office dışı proje.
Aşağıdaki derlemelere başvurur:
Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.dll (proje .NET Framework 4 veya .NET Framework 4.5'i hedefliyorsa).
veya
Microsoft.VisualStudio.Tools.Applications.ServerDocument.v10.0.dll ve Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0.dll (proje .NET Framework 3.5'i hedefliyorsa).
Imports
(Visual Basic için) veyausing
kod dosyanızın üst kısmındaki ve Microsoft.VisualStudio.Tools.Applications.Runtime ad alanları için Microsoft.VisualStudio.Tools.Applications (C#için) deyimleri.
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
Açıklamalar
Belgeyi salt okunur veya salt yazma erişimiyle açmak istiyorsanız, diskteki bir belgedeki önbelleğe alınmış verilere veya dağıtım bildirimi bilgilerine erişmek için bu oluşturucuyu kullanın. Varsayılan olarak, diğer ServerDocument oluşturucular belgeyi okuma/yazma erişimiyle açar.