Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How to handle an IO Exception in code because when the error "System.IO.IOException" occurs, the exe continues to run and the operator has to manually kill the process on the windows server?

I created an exe from the attached source code (see attached B.TXT file). Do you know how I could revise this code to have the executable end gracefully when the following exception occurs?

Unhandled Exception: System.IO.IOException: The process cannot access the file because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
   at System.IO.File.Move(String sourceFileName, String destFileName)
   at ReadXML2.FileTest.ProcessFile(String filePathIn, String filePathOut1, String filePathOut2, String filePathOut3)
   at ReadXML2.FileTest.Main()
B.txt
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

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