Load file from local disk

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Conversion MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

To load the source file from a local disk, use the following implementations of the Converter class constructor:

All these constructors have the filePath string parameter which specifies the location of the source file. File path can be absolute or relative. If the source file does not exist, an exception occurs.

GroupDocs.Conversion will open the file for reading only when any other methods of the Converter class are called.

The following code snippet shows how to load a file from a local disk:

public static void Run()
{
    // Specify source file location
    using (Converter converter = new Converter("c:\\files\\sample.docx")) 
    {
        PdfConvertOptions options = new PdfConvertOptions();
        // Specify output file location
        converter.Convert("c:\\files\\converted.pdf", options);
    }
}

You can also use the FluentConverter.Load(string fileName) and FluentConverter.Load(string[] fileName) fluent syntax methods to load the source file from a local disk.

public static void Run()
{
FluentConverter
    // Specify source file location
    .Load("c:\\files\\sample.docx")
    // Specify output file location
    .ConvertTo("c:\\files\\converted.pdf")
    .Convert();
}