我想在一个文件名和一个打印机的IP地址发送到指定打印到的打印机。
I want to send in a filename and a printer's IP address to specify which printer to print to.
我收到一个错误说设置访问打印机xxx.xxx.xxx.xxx'是无效的。当我到达printdoc.Print()。
I am getting an error saying "Settings to access printer 'xxx.xxx.xxx.xxx' are not valid." when I get to printdoc.Print().
我如何设置基于IP地址打印到的打印机?
How to I set which printer to print to based on the IP Address?
printdoc = new PrintDocument();
printdoc.PrinterSettings.PrinterName = IPAddress.Trim;
printdoc.DocumentName = FileName;
printdoc.Print();
如何解决这个问题呢?它的C#VS2010独立的Windows应用程序
How to solve this issue?Its a c# vs2010 standalone windows application
是网络为你运行你的软件的计算机打印机访问?
Is your printer accessible in network for the machine you're running your software on?
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printersettings.printername.aspx
正如你所看到的,你应该叫的IsValid
来确定是否一切正常,你也可以使用 InstalledPrinters
属性来获取系统上安装的打印机的列表。我猜你没有正确安装打印机,或者您没有足够的权限,或者类似的东西。
As you can see, you should call IsValid
to determine if everything is ok and you can also use InstalledPrinters
property to get a list of printers installed on the system. I guess you don't have installed the printer correctly or you don't have sufficient permissions or something like that.
编辑::如果使用名称的作品,这应该做的伎俩:How和网络上的IP访问C#中的打印机名称?
edit: if using name works, this should do the trick: How to access a printer name from IP on network in C#?