print,from,network,printer,c#

rou97 7/29/2016 0

this code will let your c# win app to print from network printer

C#
  IPHostEntry IPHost = Dns .GetHostEntry(PrinterName);
  string[] aliases = IPHost.Aliases;
  IPAddress[] addr = IPHost.AddressList;
  EndPoint ep = new IPEndPoint(addr[0], 9100);
  Socket sock = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType .Tcp);
  sock.Connect(ep);
  NetworkStream ns = new NetworkStream(sock);

  byte[] toSend = Encoding .ASCII.GetBytes(scriptis);
  ns.Write(toSend, 0, toSend.Length);
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments