JackW9653
asked on
Trapping for IO Exception
Hello Experts,
I have a pocket pc app that moves files to a specific folder on the network for batch printing. After the files are printed they get renamed and moved to another folder. The possibility exists the another user may try to print the same file by moving it to the print folder before the process can rename it. The files are set to read-only after printing and before the move. If that happens I get the standard message of "an unhandled exception of type IO.IOExceptions has occured in mscorlib". Is there anyway to trap for that and pause the execution of the IO.Move for a specified amount of time - say 15 seconds?
Thanks,
Jack
I have a pocket pc app that moves files to a specific folder on the network for batch printing. After the files are printed they get renamed and moved to another folder. The possibility exists the another user may try to print the same file by moving it to the print folder before the process can rename it. The files are set to read-only after printing and before the move. If that happens I get the standard message of "an unhandled exception of type IO.IOExceptions has occured in mscorlib". Is there anyway to trap for that and pause the execution of the IO.Move for a specified amount of time - say 15 seconds?
Thanks,
Jack
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
System.Threading.Thread.Sl eep()
Bob
Bob
ASKER
Omega, imported System.Threading and the sleep function worked, but still need to exit the loop when the file is copied successfully. Thanks.
In order to exit the loop, you need to set booSuccess = True.
Bob
Bob
ASKER
Where in the code above would that go?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks Bob, I removed that line and tweaked a couple of other things and it worked.
Jack
Jack
Hello, Bob,
Many thanks for your all your assistance to the OP with this. I was away from my bench all day.
As you guessed, my code was intended only as an example. The "Throw" line was there because I needed to generate an I/O error for the example, and didn't want to bother with setting up some real I/O that would fail.
Cheers.
Randy
Many thanks for your all your assistance to the OP with this. I was away from my bench all day.
As you guessed, my code was intended only as an example. The "Throw" line was there because I needed to generate an I/O error for the example, and didn't want to bother with setting up some real I/O that would fail.
Cheers.
Randy
ASKER
Yes this is what I am looking for but there are a couple issues with your routine. What namespace is thread.sleep need? I had to comment it out to get it to compile. And after success I have to hit cancel to exit the loop. But we are close.
Thanks for your help.