-
November 22nd, 2012, 06:34 AM
#1
Help With Project Please
The idea is for the program to be simple command line program.
The program basically looks in a defined directory and opens the contained HTML file in IE and then prints them. However I think from the two errors I'm getting it looks like I've over looked something, do you have any suggestions?
Ideally I'm would like the program to stay as a single Class.
My errros are:
'Bulk_Pdf.Main.Main(string)': a static constructor must be parameterless (CS0132) - C:\Users\Ben\Desktop\bulkPrint_pdf.cs:16,18
'Bulk_Pdf.Main.Main(string)': access modifiers are not allowed on static constructors (CS0515) - C:\Users\Ben\Desktop\bulkPrint_pdf.cs:16,18
Do you havee any suggestions?
Code:
using System;
using System.IO;
namespace HTML_Print
{
class Main
{
private static Main(string dirPath)
{
// Define Working Directory
DirectoryInfo dir = new DirectoryInfo(@"C:\fileDump");
// Define File Type
foreach (FileInfo finfo in dir.GetFiles("*.html"))
// Open IE Explorer and Print
if (Application.Current.Properties["finfo"] != null)
{
string fname = Application.Current.Properties["finfo"].ToString();
if (String.IsNullOrEmpty(fname))
{
fileLabel.Content = "No File Specified";
}
else
{
fileLabel.Content = fname;
SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
IE.DocumentComplete +=new SHDocVw.DWebBrowserEvents2_DocumentCompleteEventHandler(IE_DocumentComplete);
IE.PrintTemplateTeardown += new SHDocVw.DWebBrowserEvents2_PrintTemplateTeardownEventHandler(IE_PrintTemplateTeardown);
IE.Visible = true;
IE.Navigate2(fname);
}
}
}
void IE_PrintTemplateTeardown(object pDisp)
{
if (pDisp is SHDocVw.InternetExplorer)
{
SHDocVw.InternetExplorer IE = (SHDocVw.InternetExplorer)pDisp;
IE.Quit();
System.Environment.Exit(0);
}
}
void IE_DocumentComplete(object pDisp, ref object URL)
{
if (pDisp is SHDocVw.InternetExplorer)
{
SHDocVw.InternetExplorer IE = (SHDocVw.InternetExplorer)pDisp;
IE.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, 2);
}
}
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|