Load file from local disk
Leave feedback
To load the source file from a local disk, use the following implementations of the Converter class constructor:
- Converter(string filePath)
- Converter(string filePath, Func
settings) - Converter(string filePath, Func
loadOptions) - Converter(string filePath, Func
loadOptions, Func settings) - Converter(string filePath, Func<FileType, LoadOptions> loadOptions)
- Converter(string filePath, Func<FileType, LoadOptions> loadOptions, Func
settings)
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();
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.