Click or drag to resize

DocLoadOptions Class

Represents a class that stores loading options for Microsoft Word 97-2003 (DOC) format.
Inheritance Hierarchy
SystemObject
  SautinSoft.DocumentLoadOptions
    SautinSoft.DocumentDocLoadOptions

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.4.24
Syntax
public sealed class DocLoadOptions : LoadOptions

The DocLoadOptions type exposes the following members.

Constructors
 NameDescription
Public methodDocLoadOptions Initializes a new instance of the DocLoadOptions class.
Top
Example

See Developer Guide: How to load a DOC (Word 97-2003) document

How to load a DOC (Word 97-2003) document in C#
using System;
using System.IO;
using SautinSoft.Document;

namespace Example
{
    class Program
    {      
        static void Main(string[] args)
        {
            // Get your free 30-day key here:   
            // https://sautinsoft.com/start-for-free/

            LoadDocFromFile();
            //LoadDocFromStream();
        }

        /// <summary>
        /// Loads a DOC (Word 97-2003) document into DocumentCore (dc) from a file.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-doc-word-97-2003-document-net-csharp-vb.php
        /// </remarks>
        static void LoadDocFromFile()
        {
            string filePath = @"..\..\..\example.doc";
            // The file format is detected automatically from the file extension: ".doc".
            // But as shown in the example below, we can specify DocLoadOptions as 2nd parameter
            // to explicitly set that a loadable document has DOC format.
            DocumentCore dc = DocumentCore.Load(filePath);

            if (dc != null)
                Console.WriteLine("Loaded successfully!");

            Console.ReadKey();
        }

        /// <summary>
        /// Loads a DOC (Word 97-2003) document into DocumentCore (dc) from a MemoryStream.
        /// </summary>
        /// <remarks>
        /// Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-doc-word-97-2003-document-net-csharp-vb.php
        /// </remarks>
        static void LoadDocFromStream()
        {
            // Assume that we already have a DOC (Word 97-2003) document as bytes array.
            byte[] fileBytes = File.ReadAllBytes(@"..\..\..\example.doc");

            DocumentCore dc = null;

            // Create a MemoryStream
            using (MemoryStream ms = new MemoryStream(fileBytes))
            {
                // Load a document from the MemoryStream.
                // Specifying DocLoadOptions we explicitly set that a loadable document is DOC.
                dc = DocumentCore.Load(ms, new DocLoadOptions());
            }
            if (dc != null)
                Console.WriteLine("Loaded successfully!");

            Console.ReadKey();            
        }
    }
}
How to load a DOC (Word 97-2003) document in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        LoadDocFromFile()
        'LoadDocFromStream();
    End Sub
        ''' Get your free 30-day key here:   
        ''' https://sautinsoft.com/start-for-free/
    ''' <summary>
    ''' Loads a DOC (Word 97-2003) document into DocumentCore (dc) from a file.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-doc-word-97-2003-document-net-csharp-vb.php
    ''' </remarks>
    Sub LoadDocFromFile()
        Dim filePath As String = "..\..\..\example.doc"
        ' The file format is detected automatically from the file extension: ".doc".
        ' But as shown in the example below, we can specify DocLoadOptions as 2nd parameter
        ' to explicitly set that a loadable document has DOC format.
        Dim dc As DocumentCore = DocumentCore.Load(filePath)

        If dc IsNot Nothing Then
            Console.WriteLine("Loaded successfully!")
        End If

        Console.ReadKey()
    End Sub

    ''' <summary>
    ''' Loads a DOC (Word 97-2003) document into DocumentCore (dc) from a MemoryStream.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://www.sautinsoft.com/products/document/help/net/developer-guide/load-doc-word-97-2003-document-net-csharp-vb.php
    ''' </remarks>
    Sub LoadDocFromStream()
        ' Assume that we already have a DOC (Word 97-2003) document as bytes array.
        Dim fileBytes() As Byte = File.ReadAllBytes("..\..\..\example.doc")

        Dim dc As DocumentCore = Nothing

        ' Create a MemoryStream
        Using ms As New MemoryStream(fileBytes)
            ' Load a document from the MemoryStream.
            ' Specifying DocLoadOptions we explicitly set that a loadable document is DOC.
            dc = DocumentCore.Load(ms, New DocLoadOptions())
        End Using
        If dc IsNot Nothing Then
            Console.WriteLine("Loaded successfully!")
        End If

        Console.ReadKey()
    End Sub
End Module
See Also