I want to read a folder for all the files and programmatically print them as though I right-click > print.
I am aware printing this way is default-application specific. So I think this is a two step procedure: How do I check whether a file with its default application supports print; and how do I actually issue the command to print the file?
Is printing this way called “shell command printing” or something like that? Will need the correct terms for googling for information.
Any other better ways you would suggest for this task?
EDIT: The files types can be anything other than simple .txt files e.g. PDF, DWG, JPEG etc.
You can enumerate the files in the folder using Directory.GetFiles and then use the ShellExecute mode of
Process.Startto execute the “print” verb (command) on each of the files in turn.See Process.Start here, and you will need to pass in a ProcessStartInfo with the
UseShellExecuteandVerbset appropriately.By asking the operating system to work out how to print them, you don’t have to worry about the intricacies of how to print different types of data, etc.