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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
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