Hi,
Is there a way to send a .txt to a printer using c#?
something like
string doc = "c:\temp.txt";
sendToPrinter(doc);
Hi,
Is there a way to send a .txt to a printer using c#?
something like
string doc = "c:\temp.txt";
sendToPrinter(doc);
This is what I've used recently.
public void Print(FileInfo file)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "print";
psi.Arguments = string.Format("/D:\"{0}\" \"{1}\"", Printer, file.FullName);
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
Process p = new Process();
p.StartInfo = psi;
p.Start();
while (!p.HasExited) ;
}
MS has a newer document for .NET on How to: Print a Multi-Page Text File in Windows Forms for .NET 2.0, 3.0, 3.5, and 4.0.
It's essentially a newer, more complete version of the document in luvieere's answer, which was written for .NET 1.1