Static method.

Converts all files in the folder, and optionally all subfolders, using the requested conversion settings.

A filter pattern can be used to only process files in the folder that match the provided pattern, such as *.doc to process all Word documents, or ABC* to process all files that start with the letters ABC.

An exclude filter is also provided, to allow you to skip files that match the exclude pattern.


PNConverter.ConvertFolder(InputFolder, IncludeSubFolders, Filter, ExcludeFilter,

                          OutputFolder, OverwriteExisting, RemoveFileExtension, CreateResultsLogFiles,

                          SettingsProfile, ExtensionsProfile, MIMEProfile, UserSettings,

                          RemoteComputerName, ConversionWorkingFolder,



PNConverter.ConvertFolder(InputFolder, IncludeSubFolders, Filter, ExcludeFilter,

                          OutputFolder, OverwriteExisting, RemoveFileExtension, CreateResultsLogFiles,

                          SettingsProfile, ExtensionsProfile, MIMEProfile, UserSettings,

                          RemoteComputerName, ConversionWorkingFolder,


                          SortOrder, SortMode)


PNConverter.ConvertFolder(InputFolder, IncludeSubFolders, Filter, ExcludeFilter,

                          OutputFolder, OverwriteExisting, RemoveFileExtension, CreateResultsLogFiles,

                          SettingsList, ExtensionsProfile, MIMEProfile, UserSettings,

                          RemoteComputerName, ConversionWorkingFolder,



PNConverter.ConvertFolder(InputFolder, IncludeSubFolders, Filter, ExcludeFilter,

                          OutputFolder, OverwriteExisting, RemoveFileExtension, CreateResultsLogFiles,

                          SettingsList, ExtensionsProfile, MIMEProfile, UserSettings,

                          RemoteComputerName, ConversionWorkingFolder,


                          SortOrder, SortMode)


Returns an IList of PNConversionItem objects, one for each file in the folder (and subfolders, if selected) that matched the filter pattern. Each PNConversionItem contains information about the original conversion request and an inner PNConversionResult object containing information about the conversion results.


String InputFolder

The full path to the folder containing the files to convert. This can be on the local computer, on a shared location using a mapped drive letter or by passing a UNC formatted file path.

String IncludeSubFolders

Set to True to include the subfolders under the folder when building the list of files to be converted.

String Filter

A filter to process only the files matching the filter pattern, such as using *.pdf to only process files ending with the .PDF or .pdf extension. Multiple filters can be combined using the pipe (|) character, such as *.doc|*.pdf to process only Word and PDF files.

Hidden and system files are ignored, and the search pattern filters files based on a regular expression match of the long name of a file. The filter defaults to all files in the folder (*.*) if String.Empty or null are passed for the filter.

String ExcludeFilter

After the Filter pattern is used to get the list of files to convert from the InputFolder, the exclude filter can then be applied to that list to remove files that match the exclude pattern. Multiple excluded filters are combined using the pipe (|) character, such as *.pdf|*.xml to process all files returned except PDF and XML files.

If String.Empty or null is passed then no files are excluded.

String OutputFolder

Full path to the save file location. If this argument is not specified, a .new folder named .converted is created in the same location as the source file and all output files are saved there.

If the path doesn't exist, the conversion will fail, or if a file of the same name already exists in the save file location, the conversion will fail. Pass True for OverwriteExisting to allow file overwriting.

String OverwriteExisting

Set to True to overwrite existing files, or False to fail conversion when a file of the same name already exists in the save location.

String RemoveFileExtension

Set this to True if you do not want the original file name extension as part of your output file name. Normally the name of the each output file is created using the base name and file extension of the original file to prevent name collision when you have two files in the folder with the same base name.

String CreateResultsLogFile

Pass True to create a results log file containing a complete snapshot of the conversion information for each file. This log file is saved with each output file. The name of the results log file is based on the name of the original file and also indicates the conversion status. For example, when converting Sample.doc, a successful conversion will create Sample.doc.succeeded.dcsresults and if the conversion did not succeed, the file would be named Sample.doc.failed.dcsresults.

These log files can later be read from disk using the DeserializeFromXML method of the PNConversionItem class.

String SettingsProfile

The name of the profile to use, with or without the XML extension. Document Conversion Service includes several sample profiles for common types of output files for your use, or you can create your own and pass in a full path to your custom profile. See Creating and Customizing Profiles for a list of included profiles and how to create your own.

IDictionary<String, String> SettingsList

A dictionary of name\value pairs of settings that describes the conversion options. The name\value pairs that make up this dictionary are the same settings that are used to create the XML-formatted profiles included with Document Conversion Service. See Conversion Settings for a list of all of the settings that are available.

String ExtensionsProfile

Name of the file mapping profile XML file, with or without the XML extension. Providing this parameter is optional and an internal default mapping is provided. You would only need to provide this file if you wanted to override the default file extension to converter mappings provided.

String MimeProfile

Reserved for future use - pass String.Empty.

IDictionary<String, String> UserSettings

Optional. Pass a dictionary of additional conversion settings. These settings will override any matching settings in either SettingsProfile or SettingsList. Pass null if not using.

String RemoteComputerName

Optional. Pass String.Empty if you are converting locally or the name of the remote computer where Document Conversion Service is running. When converting remotely, a ConversionWorkingFolder must also be provided.

String ConversionWorkingFolder

Used to provide a shared path to be used when doing remote conversion or an alternate temporary working instead of our default of the Windows TEMP folder.

This setting is required when RemoteComputerName is provided for remote conversion (DCOM) as both the local and the remote computer need access to a shared path in which to do the conversion. Pass String.Empty if you are not using this setting.

When not doing remote conversion, this setting is not required in most cases but can be useful when dealing with folder and file names longer than 255 characters. When converting a file, the conversion tool copies the file and performs the conversion in temporary staging and working folders created on demand in the default Windows temp folder. These folders need to be less than 255 characters as required by the underlying programs used by Document Conversion Service to perform conversions. When dealing with these long path and file names the default folders created can occasionally cause path names that are too long for Document Conversion Service to process. When this happens this switch can be used to set the temporary folder to a shorter path to allow processing. Again, pass String.Empty if you are not using this setting.

String ConvertFileProcessLoggingPath

Optional. Specify a path to a folder in which to store the SmartInspect logs files of any failed conversions. These files are stored in the temp folder by default and can be viewed using the SmartInspect Redistributable Console. These log files are a tracing of the entire conversion process and are not the same as the conversion results log files created when a conversion fails. See Controlling the SmartInspect Logging Files to change where these files are stored, how they are named, or to disable creation of these files.

PNFileSortMode SortMode

Optional, controls the sort order of the list of files returned from the InputFolder. Files can be sorted by name, date created or date modified. Default is None when not specfied.

PNFileSortOrder SortOrder

Optional, returns the files in Ascending (0-9, A-Z) or Descending (Z-A, 9-0) order. Default is Ascending when not specified.


If conversion of any of the files in the folder does not succeed, a folder named .failed is created in the same location as that file. Inside the .failed folder is a timestamped folder that contains the conversion results log file that is always created with each failed file. The results log file named based on the source file's name and its conversion status. For example, if converting Document.doc failed the results log file would be named Document.doc.failed.dcsresults. See Controlling the Failed Results File Location to store these files in a different location or to disable the creation of these file.





An empty, or badly formatted profile was passed for SettingsProfile

An empty list was passed for SettingsList

An empty, or badly formatted profile was passed for ExtensionsProfile.


Null or empty string passed for InputFile.

A name for RemoteComputerName was passed but no corresponding ConversionWorkingFolder specified.


InputFile doesn't exist.


The path to InputFolder is specified but does not exist or is invalid.

The path to OutputFolder is specified but does not exist or is invalid.

The path to ConversionWorkingFolder is specified but does not exist or is invalid.

See Also:

ConvertFile ConvertFileList CombineFiles CombineFolder IsConversionServiceRunning


Code Sample - C#

IList<PNConversionItem> results = new List<PNConversionItem>();
// Convert all files in C:\Test\Input except TIFF images, include subfolders
results = PNConverter.ConvertFolder(@"C:\Test\Input\", true,
                             "*.*", "*.tif",
                             true, // overwrite existing
                             false, //  do not remove file ext
                             false, // do not create log
                             "TIFF 200dpi OptimizedColor",
                             null,         // no custom user settings
                             String.Empty, // not using DCOM
                             String.Empty, // use default working folder
                             String.Empty); // do not use custom log folder


Code Sample - VB.NET

Dim results As IList(Of PNConversionItem)
' Convert all files in C:\Test\Input except TIFF images, include subfolders
resulta = PNConverter.ConvertFolder("C:\Test\Input\", _
                              "*.*""*.tif", _
                              True, _
                              False, _
                              False, _
                              "TIFF 200dpi OptimizedColor", _
                              String.Empty, _
                              String.Empty, _
                              Nothing, _
                              String.Empty, _
                              String.Empty, _