Click here to Skip to main content
15,894,307 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
The Current Design:
You click on the shortcut and a window pops up asking you for the source directory and target directory. You provide this information and then the files in one directory get copied to another directory. When I schedule this to run as a automated task, the window always pops up asking for the source dir and target dir.

What I would like:
When you schedule the program to run as an automated task, it doesn't ask the user for the source and target directories. If the user needs to change the source and target, they double click on the shortcut and the interface pops up again asking them for the source and target info.

Question:
How do I do this in C#?
Posted

Hi,
I think your problem is more about design rather than any particular language. If I read you correctly your current design is interactive and prompts the user for source and target directories.

When running unattended what is your source of directory data? One solution would be to provide a command line interface. e.g.

FileCopier srcdir targetdir

Your code could then do the following:

1) If there are any command line arguments assume that this is an unattended run.
2) Validate the arguments to ensure that the directories exist.
3) Perform your actions on the src and dest directories.
4) Write a log file so that you can check what happened when you weren't there.

Hope that helps, ....Alan.
 
Share this answer
 
Check System.Environment.UserInteractive
 
Share this answer
 


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