EDN Admin
Well-known member
Ive never really programmed with C# and Ive now got to a point where Im completey confused. Ive cobbled (yes cobbled) together some code which has either been given to me or found.
From what Ive been told I need to look into adding a static construct into the code and Ive been given an MSDN link which I have tried implimenting into the code but to no avail. Im finding it hard relating the refference material to my own code
because Im not entirly sure how they work.
The idea is for the program to be simple command line program whic will process HTML documents in a designated folder by opening them in IE and printing them one at a time.
My errros are:
<blockquote>
Bulk_Pdf.Main.Main(string): a static constructor must be parameterless (CS0132) - C:UsersBenDesktopbulkPrint_pdf.cs:16,18
Bulk_Pdf.Main.Main(string): access modifiers are not allowed on static constructors (CS0515) - C:UsersBenDesktopbulkPrint_pdf.cs:16,18
</blockquote>
Im sorry for the really poor coding, ods are if it looks good I dont deserve the credit.
Do you havee any suggestions? Any help and digestable information would a great help.
<pre class="lang-cs prettyprint prettyprinted
[/code]
View the full article
From what Ive been told I need to look into adding a static construct into the code and Ive been given an MSDN link which I have tried implimenting into the code but to no avail. Im finding it hard relating the refference material to my own code
because Im not entirly sure how they work.
The idea is for the program to be simple command line program whic will process HTML documents in a designated folder by opening them in IE and printing them one at a time.
My errros are:
<blockquote>
Bulk_Pdf.Main.Main(string): a static constructor must be parameterless (CS0132) - C:UsersBenDesktopbulkPrint_pdf.cs:16,18
Bulk_Pdf.Main.Main(string): access modifiers are not allowed on static constructors (CS0515) - C:UsersBenDesktopbulkPrint_pdf.cs:16,18
</blockquote>
Im sorry for the really poor coding, ods are if it looks good I dont deserve the credit.
Do you havee any suggestions? Any help and digestable information would a great help.
<pre class="lang-cs prettyprint prettyprinted
Code:
<span class="pln using <span class="typ System<span class="pun ;<span class="pln
using <span class="typ System<span class="pun .<span class="pln IO<span class="pun ;<span class="pln
namespace HTML_Print
<span class="pun {<span class="pln
<span class="kwd class<span class="pln <span class="typ Main<span class="pln
<span class="pun {<span class="pln
<span class="kwd private<span class="pln <span class="kwd static<span class="pln <span class="typ Main<span class="pun (<span class="kwd string<span class="pln dirPath<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="com // Define Working Directory<span class="pln
<span class="typ DirectoryInfo<span class="pln dir <span class="pun =<span class="pln <span class="kwd new<span class="pln <span class="typ DirectoryInfo<span class="pun (<span class="str @"C:fileDump"<span class="pun );<span class="pln
<span class="com // Define File Type<span class="pln
<span class="kwd foreach<span class="pln <span class="pun (<span class="typ FileInfo<span class="pln finfo <span class="kwd in<span class="pln dir<span class="pun .<span class="typ GetFiles<span class="pun (<span class="str "*.html"<span class="pun ))<span class="pln
<span class="com // Open IE Explorer and Print<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="typ Application<span class="pun .<span class="typ Current<span class="pun .<span class="typ Properties<span class="pun [<span class="str "finfo"<span class="pun ]<span class="pln <span class="pun !=<span class="pln <span class="kwd null<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="kwd string<span class="pln fname <span class="pun =<span class="pln <span class="typ Application<span class="pun .<span class="typ Current<span class="pun .<span class="typ Properties<span class="pun [<span class="str "finfo"<span class="pun ].<span class="typ ToString<span class="pun ();<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="typ String<span class="pun .<span class="typ IsNullOrEmpty<span class="pun (<span class="pln fname<span class="pun ))<span class="pln
<span class="pun {<span class="pln
fileLabel<span class="pun .<span class="typ Content<span class="pln <span class="pun =<span class="pln <span class="str "No File Specified"<span class="pun ;<span class="pln
<span class="pun }<span class="pln
<span class="kwd else<span class="pln
<span class="pun {<span class="pln
fileLabel<span class="pun .<span class="typ Content<span class="pln <span class="pun =<span class="pln fname<span class="pun ;<span class="pln
<span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pln IE <span class="pun =<span class="pln <span class="kwd new<span class="pln <span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pun ();<span class="pln
IE<span class="pun .<span class="typ DocumentComplete<span class="pln <span class="pun +=<span class="kwd new<span class="pln <span class="typ SHDocVw<span class="pun .<span class="typ DWebBrowserEvents2_DocumentCompleteEventHandler<span class="pun (<span class="pln IE_DocumentComplete<span class="pun );<span class="pln
IE<span class="pun .<span class="typ PrintTemplateTeardown<span class="pln <span class="pun +=<span class="pln <span class="kwd new<span class="pln <span class="typ SHDocVw<span class="pun .<span class="typ DWebBrowserEvents2_PrintTemplateTeardownEventHandler<span class="pun (<span class="pln IE_PrintTemplateTeardown<span class="pun );<span class="pln
IE<span class="pun .<span class="typ Visible<span class="pln <span class="pun =<span class="pln <span class="kwd true<span class="pun ;<span class="pln
IE<span class="pun .<span class="typ Navigate2<span class="pun (<span class="pln fname<span class="pun );<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="kwd void<span class="pln IE_PrintTemplateTeardown<span class="pun (<span class="kwd object<span class="pln pDisp<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="pln pDisp <span class="kwd is<span class="pln <span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pln IE <span class="pun =<span class="pln <span class="pun (<span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pun )<span class="pln pDisp<span class="pun ;<span class="pln
IE<span class="pun .<span class="typ Quit<span class="pun ();<span class="pln
<span class="typ System<span class="pun .<span class="typ Environment<span class="pun .<span class="typ Exit<span class="pun (<span class="lit 0<span class="pun );<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="kwd void<span class="pln IE_DocumentComplete<span class="pun (<span class="kwd object<span class="pln pDisp<span class="pun ,<span class="pln <span class="kwd ref<span class="pln <span class="kwd object<span class="pln URL<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="kwd if<span class="pln <span class="pun (<span class="pln pDisp <span class="kwd is<span class="pln <span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pun )<span class="pln
<span class="pun {<span class="pln
<span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pln IE <span class="pun =<span class="pln <span class="pun (<span class="typ SHDocVw<span class="pun .<span class="typ InternetExplorer<span class="pun )<span class="pln pDisp<span class="pun ;<span class="pln
IE<span class="pun .<span class="typ ExecWB<span class="pun (<span class="typ SHDocVw<span class="pun .<span class="pln OLECMDID<span class="pun .<span class="pln OLECMDID_PRINT<span class="pun ,<span class="pln <span class="typ SHDocVw<span class="pun .<span class="pln OLECMDEXECOPT<span class="pun .<span class="pln OLECMDEXECOPT_DONTPROMPTUSER<span class="pun ,<span class="pln <span class="lit 2<span class="pun );<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="pun }<span class="pln
<span class="pun }
View the full article