If you are trying to get that code to work in a ASP.NET scenario, then forget it, it won't work.
Sorry, that "could" work if the printer is attached to the
server where your ASP.NET website is hosted. But that will not work if your intention is to
allow your users to print to their client printers
If you want to send raw printer commands to the client printer from your ASP.NET website, then you'll need help from an external tool like
this or
this as there's no way to do that by using just ASP.NET framework.