IE浏览器怎么打印HTML文档,循环浏览文件夹中的HTML文件并通过IE默认打印到默认打印机通过IE浏览器...

这个想法是让程序变成简单的命令行程序。

我发现了一个稍微简单一些的骑车通过我的文件,我认为你的代码已被正确添加。然而,我认为从我得到的两个错误看来,我已经看过一些东西,你有什么建议吗?

理想情况下,我希望程序保持为一个类。

我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);

}

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值