Winforms app as a console app

  • Thread starter Omkumar Enkannathan
  • Start date

O

Omkumar Enkannathan

Hai,

I wrote a windows forms application and everything is fine. From this app, I
am inserting data from a text file to a database table.

How do I run this application from command line? The user would pass the
server name, db name and the text file as arguments.

My main problem is how do I report status back to the console window while
it is loading the data?

thanks,
omkamal.
 
Ad

Advertisements

J

Jon Skeet [C# MVP]

Omkumar Enkannathan said:
I wrote a windows forms application and everything is fine. From this app, I
am inserting data from a text file to a database table.

How do I run this application from command line? The user would pass the
server name, db name and the text file as arguments.
That bit is easy - just use Main (String[] args) as you would for any
other app.
My main problem is how do I report status back to the console window while
it is loading the data?
That's harder - but do you definitely need to report the status back to
the console window? Can't you pop up a progress bar saying that you're
loading data?
 
O

Omkumar Enkannathan

Thanks for your reply. I figured out the first part as you said. But I
cannot popup a progress bar. I need to write the log to the console window,
because its not just saying "Loading data...". Its a bit more than that.

--
Om.
Jon Skeet said:
Omkumar Enkannathan said:
I wrote a windows forms application and everything is fine. From this app, I
am inserting data from a text file to a database table.

How do I run this application from command line? The user would pass the
server name, db name and the text file as arguments.
That bit is easy - just use Main (String[] args) as you would for any
other app.
My main problem is how do I report status back to the console window while
it is loading the data?
That's harder - but do you definitely need to report the status back to
the console window? Can't you pop up a progress bar saying that you're
loading data?
 
H

Herfried K. Wagner [MVP]

* "Omkumar Enkannathan said:
Thanks for your reply. I figured out the first part as you said. But I
cannot popup a progress bar. I need to write the log to the console window,
because its not just saying "Loading data...". Its a bit more than that.
Why not create a console application which shows a window?
 
B

Bob Powell [MVP]

If you create a Windows Forms application but compile it as a console app,
it will start a console when it first runs and then work as a winforms app
as soon as it hits the Application.Run(new Form1()) line.

Any thing you do with Console.WriteLine will turn up on the console.

--
Bob Powell [MVP]
C#, System.Drawing

September's edition of Well Formed is now available.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Blog http://bobpowelldotnet.blogspot.com
 
P

pedagogue

Can you tell me how to compile a winforms app to a console app?

Thanks.
 
Ad

Advertisements

J

Jon Skeet [C# MVP]

pedagogue said:
Can you tell me how to compile a winforms app to a console app?
Just change the project type to "Console Application". The potential
downside of this is that if you double-click on it in Explorer, you'll
still get a console.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top