Link to home
Start Free TrialLog in
Avatar of llucy88
llucy88

asked on

Shellexecute question

I am writing a program to monitor certain folder(using timer control). If there are txt files coming into this folder, my program will use shellexecute to invoke another exe. file by using "shellexecute" to process the txt file, after that delete it. The problem is: after I "shellexecute", I don't know if the exe finishes running (as this exe will process the text file and insert records to the sql server database.) Since I have to delete the text file after the "shellexecute" finish processing it. That cause a lot of problems: 1. while the shellexcute still processing the file, the timer event invoke again. 2. The shellexecute still running, the text file is already being deleted.

How should I make sure the first file is being processed by shellexecute before going to the next process?

Any suggestion will be appreciated!

llucy
ASKER CERTIFIED SOLUTION
Avatar of Cynna
Cynna

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
Avatar of d32coder
d32coder

or  move the text file to another folder then launch the exe there.


New file goes to C:\INCOMING
Your prog moves the file to  C:\WORKING
Shellexecute the exe to the file in WORKING
The timer still looking for new files in INCOMING

The *Other* exe should delete the text file when it is done processing it.

no errors

Don
Avatar of aikimark
Or ...
1. create a parameterized .CMD file that runs the program and then deletes the file.
2. shellexecute the .CMD file, passing the name of the .txt file, and forget about it.

============================================
Example of .CMD file

"C:\Program Files\App Name\Appl.exe" %1
Del %1

REM %1 is fully qualified path of .txt file