Click here to Skip to main content
16,017,238 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I am generating text file like report-1, report-2 etc.

Now while printing how to print them at a single command.

means sometime there may be 2 report files or may be 4.

so how to write the loop to take all the files and print them one by one with a delay.

C#
int lines = File.ReadAllLines(@"C:\ReportPrint.txt").Count();
                                

if (printerType == "2 Inch Printer" && lines > 50)
{
  splitfiles();
  string s = "CMD /c COPY " + Program.DeptFilePath + "ReportPrint-1.txt" + " " +   billingBHWS.TokenPrinter;
  Interaction.Shell(s, AppWinStyle.Hide, false, 1000);
  string s11 = "CMD /c COPY " + Program.DeptFilePath + "ReportPrint-2.txt" + " " + billingBHWS.TokenPrinter;
  Interaction.Shell(s11, AppWinStyle.Hide, false, 1000);
  string s22 = "CMD /c COPY " + Program.DeptFilePath + "ReportPrint-3.txt" + " " + billingBHWS.TokenPrinter;
  Interaction.Shell(s22, AppWinStyle.Hide, false, 1000);
break;


This is the code i am using now for printing.here my report file is fix (i.e. 3)so i wrote like this.
This i want to make in single line.

Please tell me how to do this..
Posted
Comments
Richard MacCutchan 5-Mar-14 5:04am    
Use a loop, and a string formatter to generate the file names. Or use a file name searcher to find all the file names waiting to be printed.
[no name] 5-Mar-14 5:09am    
Please give me some example..
Richard MacCutchan 5-Mar-14 6:37am    
Example of what? Are you saying you don't know how to write a loop, or use the string.Format method?

1 solution

You just need to put an outer loop and loop through all the files in the directory, or whatever your business logic is.

For an example see http://stackoverflow.com/questions/4254339/how-to-loop-through-all-the-files-in-a-directory-in-c-net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900