Get up to 80 % extra points for free! More info:

Discussion: Using PrintDialog() in Console Application

In the previous quiz, Online C#.NET Quiz, we tested our experience gained from the course.

Activities
Avatar
Hares
Member
Avatar
Hares:7/13/2018 20:45

I'm attempting to create a console app executable for my company that batch prints folders. The code loops through a folder, and outputs images. I'd like to have a printdialog option available, to adjust settings easily. I want one print dialog to adjust settings once, then to loop through all the files using those settings. Is there a way for me to wrap my code below under a printDialog() event? I can try form later, but for now i want to try a printdialog() to run once, for all the files to be printed in a directory. Could anyone help me out with this?

Module Module1


    Sub Main()
          Dim files() as String = IO.Directory.GetFiles("\\sv-fs03\users$\hfakoor\Desktop\Driven\dwg printer")
    For Each file In files

      Try

                 Dim psi As New ProcessStartInfo(file)
        psi.Verb = "print"
        psi.UseShellExecute = True
        psi.WindowStyle = ProcessWindowStyle.Hidden
        psi.CreateNoWindow = True
        Process.Start(psi).WaitForExit(5000)
      Catch ex As Exception
        Console.WriteLine(File)
      End Try
Next file
        Console.WriteLine("Done.")
Console.ReadKey
    End Sub

End Module
 
Reply
7/13/2018 20:45
Avatar
Replies to Hares
David Capka Hartinger:7/14/2018 6:36

What data do you need to pass from the printer dialog?

As you say, I'd really rather try forms and the PrintDialog class https://msdn.microsoft.com/…vs.110).aspx?….

You can find your problem solved here: https://social.msdn.microsoft.com/…ific-printer?…

Usage of the PrintDialog class:

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim psi As New ProcessStartInfo

        psi.UseShellExecute = True

        psi.Verb = "print"

        psi.WindowStyle = ProcessWindowStyle.Hidden

psi.Arguments = PrintDialog1.PrinterSettings.PrinterName.ToString()' Here specify printer name

        psi.FileName = "C:\MyFile.doc" ' Here specify a document to be printed

        Process.Start(psi)

    End Sub

End Class
Up Reply
7/14/2018 6:36
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Hares
Member
Avatar
Replies to David Capka Hartinger
Hares:7/14/2018 22:38

I want all the contents in my folder (which may or may not be read into a stream) to get printed with one print setting for all of them. Hence, I want to pass the contents of the folder to a printdialog().

Worst case scenario I can print it to the file system, but this limits how the files will be outputted.

I can get everything read into a stream(if needed) etc, my issue has been wrapping my set of files/loop inside one instance of a printdialog()

 
Up Reply
7/14/2018 22:38
Avatar
Replies to Hares
David Capka Hartinger:7/15/2018 9:21

Yes, I understand. But the way you're doing it is just wrong IMHO. Just invest some of your time and learn how to do forms. Printing is then quite easy. There are PrintDialog and PrintDocument classes for that.

Up Reply
7/15/2018 9:21
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
Samuel Jackson:12/24/2021 5:14

I feel really very happy to have seen your this post and look forward to read so many more interesting post here.

 
Up Reply
12/24/2021 5:14
Avatar
Jon Cortez
Member
Avatar
Jon Cortez:6/19/2022 17:54

Interesting article, need pay someone to do my essay ?! Every essay writer on the team is a real expert. Give us any topic in any of the 25+ subject fields that we cover, including MBA, History, Literature, Nursing, and Education.

 
Up Reply
6/19/2022 17:54
Avatar
Eve Hoddle
Member
Avatar
Eve Hoddle:7/25/2022 15:47

You can simplify writing a resume simply by hiring a topresume review, in addition to tips on writing a resume, there are also creative professional resumes, which is very good for those who need a resume

 
Up Reply
7/25/2022 15:47
Avatar
Thomas Ericson:3/4/2023 14:08

This essay writing service is the best! The writers are knowledgeable and dedicated to providing you with the best work. The customer service team is friendly and always willing to answer your questions buy an assignment online. They provide feedback along the way, helping you understand the process and make sure your work is perfect. Highly recommend!

 
Up Reply
3/4/2023 14:08
Avatar
frederickgragg:5/26/2023 8:13

The education is necessary because through this you become an expert and get acknowledge about different important aspects. Certsboard products contain information that has been extracted from authentic and reliable sources. certsboard.com offer you updated knowledge about all the contents of the syllabus and will enable you to pass it with flying colors. If you need to go through the entire syllabus and learn each and every topic, choose our Study Guides that equip you with the best knowledge.

 
Up Reply
5/26/2023 8:13
Avatar
David worner
Member
Avatar
David worner:9/22/2023 10:27

Fort Lauderdale has specific building codes and regulations that must be followed. Obtaining the necessary permits and ensuring compliance with local codes will add to the cost. https://www.acompio.us/…6809830.html

 
Up Reply
9/22/2023 10:27
Avatar
Sharonfrankklin:12/21/2023 2:02

Disposable vape RabBeats Products bundles typically come with a fully charged battery. This means you can start vaping immediately without the need to worry about charging cables or finding power outlets.

 
Up Reply
12/21/2023 2:02
Avatar
RyanAnderes
Member
Avatar
RyanAnderes:24. May 1:50

The HPE7-A01 questions answers is designed for IT professionals who have a strong foundation in designing and implementing advanced Aruba Wireless solutions. Achieving this certification demonstrates your proficiency in a variety of areas, including Aruba architecture, WLANs, mobility, and security solutions.

 
Up Reply
24. May 1:50
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

12 messages from 12 displayed.