这个想法是让程序变成简单的命令行程序。
我发现了一个稍微简单一些的骑车通过我的文件,我认为你的代码已被正确添加。然而,我认为从我得到的两个错误看来,我已经看过一些东西,你有什么建议吗?
理想情况下,我希望程序保持为一个类。
我errros是:
'Bulk_Pdf.Main.Main(串)':静态构造函数必须是 参(CS0132) - C:\用户\本\桌面\ bulkPrint_pdf.cs:16 ,18
'Bulk_Pdf.Main.Main(串)':访问修饰符不允许在 静态构造函数(CS0515) - C:\用户\本\桌面\ bulkPrint_pdf.cs:16,18
你有没有Ÿ建议?
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);
}
}
}
}