system calls, OS functions, cmd command using C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How does C# implement system calls in the old terms?
As in C system("OSfunction");
I want to copy a file to the printer port for direct PCL (printer control
language) execution. In cmd it will be "copy file lpt1" or similar
 
Dbug,

You might want to take a look at the Process class, specifically, the
static Start method, as this will do what you want it to do.

However, it might be cleaner to open up a handle to the printer
yourself, and write the contents directly to it using a combination of the
OpenFile API through P/Invoke, and then the FileStream class.

Hope this helps.
 
Look at System.Diagnostics.Process

Create a new process with "cmd.exe" as the name of the program to run, and
"/C copy file lpt1" as the arguments. Note: Using the /C switch tells cmd.exe
to exit after carrying out this command.

Hope this helps.

Brian.
 
Thanks
Process myProcess = Process.Start("cmd","/C copy c:\\file.txt lpt1");
works, and also
File.Copy(@"c:\file.txt", "lpt1");

for debugging you can use the /K instead of /C or even route the output to a
file
Process myProcess = Process.Start("cmd","/C dir * > temp.txt");
You may have to include the directory in the input and output also.
 
Back
Top