Link to home
Start Free TrialLog in
Avatar of sovroc81
sovroc81Flag for United States of America

asked on

How to run same application as a console(scheduled application) and in windows form(manual)

I want to develop an application. Basic thing to do for it is to look for files in a folder. When it finds files, do some action and delete files. However, this is an scheduled once a day routine. Sometimes, I should be able to forcefully run this application and enter the filename and do action only to that filename without bothering other files. How can I utilize these both events in one application.
Please help.
Avatar of sovroc81
sovroc81
Flag of United States of America image

ASKER

Same question can be asked this way.

In the start of the console window application, can I make user to input filename by waiting for 15 seconds or so. If I don't get the input within that time, can I proceed with Process1 else proceed with Process2.

The input can be accepted in the form of any keystroke (if not the whole fileName).

I don't how to make them wait for 15 second for the response.
Avatar of dstanley9
dstanley9

Why not just make the filename an input argument, and have another input argument to tell in to run in "auto" mode (so you don't accidentally run in auto mode if you forget to add parameters)?

e.g.

MyApp.exe -f *.txt   // process all text files
MyApp.exe -f textfile.txt // process single file
MyApp.exe -a // Auto processing (maybe with defaults specified in config.xml)
MyApp.exe -? // Show syntax and options.
Can you give an example of what you are trying to say?
Thank you!!!
According to your example, you are asking me to input value in commandline for each time I call manually. Is their a easier way to invoke exe file with parameters. Can I do it in a small window application instead, obtaining the parameter from a textbox.
ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your promptness.
Can you show me how to put this into a separate window application and call from there?
Build the logic pieces as a class library (DLL), then reference the class library from your console app, and also create a Windows app that references and uses the classes.  There's not really a "cookie-cutter" way to do it.

To be honest, the console app with parameters will be much easier to build; adding on a GUI after the fact will take some re-writing.
You are right. It is definitely a painstaking process, but at this time, I got the answer and I got it right.

Thanks for your help for showing the insight.