I’m trying to cobble together a short bit of console code to print some HTML files in a folder through Internet Explorer to the default printer. I have found a the following code below from http://weblogs.asp.net/israelio/archive/2004/06/23/162913.aspx which appears to almost suit my needs.
I have have made a couple of alterations but my programming skills are very limited. I’m looking for some help making sure the syntax is correct and someone to show me how to silently print via Internet Explorer and not to open Internet Explorer as I beleive it stands now.
Any help would be greatly appreaciated…
using System
using System.IO
// How much deep to scan. (of course you can also pass it to the method)
const int HowDeepToScan=4;
public static void ProcessDir(string sourceDir, int recursionLvl)
{
if (recursionLvl<=HowDeepToScan)
{
// Process the list of files found in the directory.
string [] fileEntries = Directory.GetFiles(@"C:\fileDump\", "*.html");
foreach(string fileName in fileEntries)
{
// do something with fileName
System.Diagnostics.Process.Start(fileName);
}
// Recurse into subdirectories of this directory.
string [] subdirEntries = Directory.GetDirectories((@"C:\fileDump);
foreach(string subdir in subdirEntries)
// Do not iterate through reparse points
if ((File.GetAttributes(subdir) &
FileAttributes.ReparsePoint) !=
FileAttributes.ReparsePoint)
ProcessDir(subdir,recursionLvl+1);
}
}
I had a similar (but different) problem to solve and the code I used may be able to help you.
Background to my problem
Create a program which when used to open a file (in this case .MHTML files) would in fact open it with IE, immediatly print the page and the close IE
CODE
NOTES
Once youve incorporated this into your file loop you would need to change
IE.Visible = true;toIE.Visible = false;this prevents the IE window displaying.